mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Gestion multi-profil multi-école
This commit is contained in:
@ -11,24 +11,23 @@ const options = {
|
||||
name: 'Credentials',
|
||||
credentials: {
|
||||
email: { label: 'Email', type: 'email' },
|
||||
password: { label: 'Password', type: 'password' }
|
||||
password: { label: 'Password', type: 'password' },
|
||||
role_type: { label: 'Role Type', type: 'text' }
|
||||
},
|
||||
authorize: async (credentials, req) => {
|
||||
try {
|
||||
const data = {
|
||||
email: credentials.email,
|
||||
password: credentials.password
|
||||
password: credentials.password,
|
||||
role_type: credentials.role_type
|
||||
};
|
||||
|
||||
const user = await getJWT(data);
|
||||
|
||||
if (user) {
|
||||
logger.debug("API response:", user);
|
||||
return user;
|
||||
}
|
||||
logger.error('Invalid credentials')
|
||||
} catch (error) {
|
||||
logger.error('Invalid credentials')
|
||||
throw new Error(error.message || 'Invalid credentials');
|
||||
}
|
||||
}
|
||||
@ -88,16 +87,15 @@ const options = {
|
||||
},
|
||||
async session({ session, token }) {
|
||||
if (token && token?.token) {
|
||||
const {user_id, droit, email, establishment} = jwt_decode.decode(token.token);
|
||||
const { user_id, email, roles } = jwt_decode.decode(token.token);
|
||||
session.user = {
|
||||
...session.user,
|
||||
token: token.token,
|
||||
refresh: token.refresh
|
||||
refresh: token.refresh,
|
||||
user_id: user_id,
|
||||
email: email,
|
||||
roles: roles
|
||||
};
|
||||
session.user.user_id = user_id;
|
||||
session.user.droit = droit;
|
||||
session.user.email = email;
|
||||
session.user.establishment = establishment;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user