Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
♻️ Use constant for login token sub
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 3, 2020
1 parent c17753e commit aa80db1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions http/users/get.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@baseUrl = http://localhost:3000
@userId = 1

GET {{baseUrl}}/users/{{userId}}
content-type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMSIsInNjb3BlcyI6WyJ1c2VyLTE6KiJdLCJpYXQiOjE2MDQ0MDY1NjksImV4cCI6MTYwNDQxMDE2OX0.AMBGQtM4pfdyJSopI9jnV_5bZbHTkgwuOrC1ttyYvwk
3 changes: 2 additions & 1 deletion src/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
MULTI_FACTOR_TOKEN,
PASSWORD_RESET_TOKEN,
EMAIL_MFA_TOKEN,
LOGIN_ACCESS_TOKEN,
} from '../tokens/tokens.constants';
import { TokensService } from '../tokens/tokens.service';
import { RegisterDto } from './auth.dto';
Expand Down Expand Up @@ -467,7 +468,7 @@ export class AuthService {
private async getAccessToken(userId: number): Promise<string> {
const scopes = await this.getScopes(userId);
const payload: AccessTokenClaims = {
sub: `user${userId}`,
sub: LOGIN_ACCESS_TOKEN,
scopes,
};
return this.jwtService.sign(payload, {
Expand Down
1 change: 1 addition & 0 deletions src/modules/tokens/tokens.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export const PASSWORD_RESET_TOKEN = 'PASSWORD_RESET_TOKEN';
export const EMAIL_VERIFY_TOKEN = 'EMAIL_VERIFY_TOKEN';
export const APPROVE_SUBNET_TOKEN = 'APPROVE_SUBNET_TOKEN';
export const EMAIL_MFA_TOKEN = 'EMAIL_MFA_TOKEN';
export const LOGIN_ACCESS_TOKEN = 'LOGIN_ACCESS_TOKEN';

0 comments on commit aa80db1

Please sign in to comment.