Feat/impersonate users (#2503)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: zomars <[email protected]>
This commit is contained in:
13 files changed
+285
-34
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
import { IdentityProvider } from "@prisma/client";
|
||||
import { IdentityProvider, UserPermissionRole } from "@prisma/client";
|
||||
import { readFileSync } from "fs";
|
||||
import Handlebars from "handlebars";
|
||||
import NextAuth, { Session } from "next-auth";
|
||||
@@ -15,6 +15,7 @@ import { WEBSITE_URL } from "@calcom/lib/constants";
|
||||
import { symmetricDecrypt } from "@calcom/lib/crypto";
|
||||
import { defaultCookies } from "@calcom/lib/default-cookies";
|
||||
import { serverConfig } from "@calcom/lib/serverConfig";
|
||||
import ImpersonationProvider from "@ee/lib/impersonation/ImpersonationProvider";
|
||||
|
||||
import { ErrorCode, verifyPassword } from "@lib/auth";
|
||||
import prisma from "@lib/prisma";
|
||||
@@ -103,9 +104,11 @@ const providers: Provider[] = [
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
role: user.role,
|
||||
};
|
||||
},
|
||||
}),
|
||||
ImpersonationProvider,
|
||||
];
|
||||
|
||||
if (IS_GOOGLE_LOGIN_ENABLED) {
|
||||
@@ -213,6 +216,8 @@ export default NextAuth({
|
||||
username: existingUser.username,
|
||||
name: existingUser.name,
|
||||
email: existingUser.email,
|
||||
role: existingUser.role,
|
||||
impersonatedByUID: token?.impersonatedByUID as number,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -229,6 +234,8 @@ export default NextAuth({
|
||||
name: user.name,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
impersonatedByUID: user?.impersonatedByUID as number,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -262,6 +269,8 @@ export default NextAuth({
|
||||
name: existingUser.name,
|
||||
username: existingUser.username,
|
||||
email: existingUser.email,
|
||||
role: existingUser.role,
|
||||
impersonatedByUID: token.impersonatedByUID as number,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -275,6 +284,8 @@ export default NextAuth({
|
||||
id: token.id as number,
|
||||
name: token.name,
|
||||
username: token.username as string,
|
||||
role: token.role as UserPermissionRole,
|
||||
impersonatedByUID: token.impersonatedByUID as number,
|
||||
},
|
||||
};
|
||||
return calendsoSession;
|
||||
|
||||
Reference in new issue
Block a user