cambios en el refresh token
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// refreshtoken
|
||||
import { z } from 'zod';
|
||||
import { tokensSchema } from './login';
|
||||
|
||||
// Esquema para el refresh token
|
||||
export const refreshTokenSchema = z.object({
|
||||
user_id: z.number(),
|
||||
token: z.string(),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//auth.config
|
||||
import { SignInAction } from '@/feactures/auth/actions/login-action';
|
||||
import { resfreshTokenAction } from '@/feactures/auth/actions/refresh-token-action';
|
||||
import { CredentialsSignin, NextAuthConfig, Session, User } from 'next-auth';
|
||||
@@ -146,7 +147,7 @@ const authConfig: NextAuthConfig = {
|
||||
// 4. Si el token de acceso ha expirado pero el refresh token es válido, renovar
|
||||
// console.log("Renovando token de acceso...");
|
||||
try {
|
||||
const res = await resfreshTokenAction({ token: token.refresh_token as string });
|
||||
const res = await resfreshTokenAction({ token: token.refresh_token as string, user_id: token.user.id as number});
|
||||
|
||||
if (!res || !res.tokens) {
|
||||
throw new Error('Fallo en la respuesta de la API de refresco.');
|
||||
@@ -185,6 +186,7 @@ const authConfig: NextAuthConfig = {
|
||||
return session;
|
||||
},
|
||||
},
|
||||
|
||||
} satisfies NextAuthConfig;
|
||||
|
||||
export default authConfig;
|
||||
|
||||
Reference in New Issue
Block a user