feat: implement user impersonation

This commit is contained in:
giriparus
2026-02-03 11:51:35 +05:30
parent 8f84fbf562
commit bc38dba859
9 changed files with 302 additions and 16 deletions
+5 -1
View File
@@ -1,4 +1,3 @@
import { pb } from '@/lib/pocketbase';
export interface LoginCredentials {
@@ -98,5 +97,10 @@ export const authService = {
} catch (error) {
// console.error('Failed to refresh user data:', error);
}
},
async impersonateUser(userId: string, durationSeconds: number = 3600): Promise<string | undefined> {
const impersonateClient = await pb.collection("users").impersonate(userId, durationSeconds);
return impersonateClient.authStore?.token;
}
};