widget chat 23
This commit is contained in:
parent
fb36b0334a
commit
48d65028f1
@ -84,7 +84,7 @@ export const authOptions: NextAuthOptions = {
|
||||
console.log('JWT callback called with:', { token, account, profile });
|
||||
|
||||
// Initial sign in
|
||||
if (account) {
|
||||
if (account && profile) {
|
||||
// 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: {
|
||||
@ -172,7 +172,12 @@ export const authOptions: NextAuthOptions = {
|
||||
return token;
|
||||
}
|
||||
|
||||
// Return previous token if not expired
|
||||
// Return previous token if it has Rocket.Chat credentials
|
||||
if (token.rocketChatToken && token.rocketChatUserId) {
|
||||
return token;
|
||||
}
|
||||
|
||||
// Token refresh case
|
||||
if (Date.now() < (token.accessTokenExpires as number)) {
|
||||
return token;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user