mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 13:17:55 +00:00
Refactor user role handling to use single role object
This commit is contained in:
@@ -4,5 +4,5 @@ export class AuthInterface {
|
||||
uuid: string;
|
||||
sessionId: string;
|
||||
id: number;
|
||||
roles?: string[];
|
||||
role?: object;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class AuthService {
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
relations: ['roles.roleType'],
|
||||
relations: ['roleType'],
|
||||
});
|
||||
|
||||
if (!user.isUserVerified) {
|
||||
@@ -85,9 +85,8 @@ export class AuthService {
|
||||
email: user.email,
|
||||
userId: user.userId,
|
||||
uuid: user.uuid,
|
||||
type: user.type,
|
||||
sessionId: user.sessionId,
|
||||
roles: user?.roles,
|
||||
role: user?.role,
|
||||
googleCode: user.googleCode,
|
||||
};
|
||||
if (payload.googleCode) {
|
||||
|
||||
@@ -31,7 +31,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
userUuid: payload.uuid,
|
||||
uuid: payload.uuid,
|
||||
sessionId: payload.sessionId,
|
||||
roles: payload?.roles,
|
||||
role: payload?.role,
|
||||
};
|
||||
} else {
|
||||
throw new BadRequestException('Unauthorized');
|
||||
|
||||
@@ -34,7 +34,7 @@ export class RefreshTokenStrategy extends PassportStrategy(
|
||||
userUuid: payload.uuid,
|
||||
uuid: payload.uuid,
|
||||
sessionId: payload.sessionId,
|
||||
roles: payload?.roles,
|
||||
role: payload?.role,
|
||||
};
|
||||
} else {
|
||||
throw new BadRequestException('Unauthorized');
|
||||
|
||||
Reference in New Issue
Block a user