widget chat 24

This commit is contained in:
Alma 2025-04-11 12:44:33 +02:00
parent 48d65028f1
commit e2da8cfca4
2 changed files with 14 additions and 4 deletions

View File

@ -85,6 +85,12 @@ export const authOptions: NextAuthOptions = {
// Initial sign in
if (account && profile) {
// Set user data from profile
token.username = profile.preferred_username;
token.first_name = profile.given_name;
token.last_name = profile.family_name;
token.role = profile.groups || [];
// Get user info from Rocket.Chat using the admin token
const userInfoResponse = await fetch(`${process.env.ROCKET_CHAT_URL}/api/v1/users.info?username=${token.username}`, {
headers: {

12
types/next-auth.d.ts vendored
View File

@ -40,10 +40,14 @@ declare module "next-auth" {
}
interface Profile {
given_name: string;
family_name: string;
preferred_username: string;
realm_roles: string[];
sub: string;
email_verified: boolean;
name?: string | null;
preferred_username?: string | null;
given_name?: string | null;
family_name?: string | null;
email?: string | null;
groups?: string[];
}
}