mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-23 10:07:55 +00:00
add client relation btw user and client
This commit is contained in:
@@ -20,6 +20,8 @@ export class ClientGuard extends AuthGuard('jwt') {
|
||||
if (!this.validateToken(decoded)) {
|
||||
throw new UnauthorizedException('Invalid token');
|
||||
}
|
||||
|
||||
request.client = (decoded as jwt.JwtPayload).client;
|
||||
} catch (err) {
|
||||
throw new UnauthorizedException('Invalid token');
|
||||
}
|
||||
@@ -36,14 +38,6 @@ export class ClientGuard extends AuthGuard('jwt') {
|
||||
}
|
||||
|
||||
private validateToken(decoded: any): boolean {
|
||||
if (
|
||||
decoded &&
|
||||
decoded.client &&
|
||||
decoded.client.clientId &&
|
||||
decoded.client.uuid
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return decoded?.client?.clientId && decoded?.client?.uuid;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user