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 // Initial sign in
if (account && profile) { 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 // 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}`, { const userInfoResponse = await fetch(`${process.env.ROCKET_CHAT_URL}/api/v1/users.info?username=${token.username}`, {
headers: { headers: {

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

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