commented out unused code, small refactorings

This commit is contained in:
Igor Hrenowitsch Propisnov 2024-05-31 08:32:44 +02:00
parent 4f8d54ebd6
commit 0a35fc6d26
8 changed files with 30 additions and 31 deletions

View File

@ -1,14 +1,13 @@
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { JwtPayloadWithRefreshToken } from 'src/modules/auth-module/models/types';
//import { JwtPayloadWithRefreshToken } from 'src/modules/auth-module/models/types';
export const GetCurrentUser = createParamDecorator(
(
data: keyof JwtPayloadWithRefreshToken | undefined,
context: ExecutionContext
) => {
const request = context.switchToHttp().getRequest();
// export const GetCurrentUser = createParamDecorator(
// (
// data: keyof JwtPayloadWithRefreshToken | undefined,
// context: ExecutionContext
// ) => {
// const request = context.switchToHttp().getRequest();
if (!data) return request.user;
return request.user[data];
}
);
// if (!data) return request.user;
// return request.user[data];
// }
// );

View File

@ -1,2 +1,2 @@
export * from './get-user-id.decorator';
export * from './get-user.decorator';
// export * from './get-user.decorator';

View File

@ -1,2 +1,4 @@
export * from './jwt-payload.type';
export * from './jwt-payload-with-refresh-token.type';
// export * from './jwt-payload-with-refresh-token.type';
export * from './token-payload.type';
export * from './tokens.type';

View File

@ -1,3 +1,3 @@
import { JwtPayload } from './jwt-payload.type';
// import { JwtPayload } from './jwt-payload.type';
export type JwtPayloadWithRefreshToken = JwtPayload & { refresh_token: string };
// export type JwtPayloadWithRefreshToken = JwtPayload & { refresh_token: string };

View File

@ -0,0 +1,6 @@
export type TokenPayload = {
sub: string;
email: string;
iat: number;
exp: number;
};

View File

@ -0,0 +1,4 @@
export type Tokens = {
access_token: string;
refresh_token: string;
};

View File

@ -11,13 +11,11 @@ import {
LoginResponseDto,
UserCredentialsDto,
} from '../models/dto';
import { TokenPayload } from '../models/types';
import { UserCredentialsRepository } from '../repositories/user-credentials.repository';
import { SessionService } from './session.service';
import {
TokenManagementService,
TokenPayload,
} from './token-management.service';
import { TokenManagementService } from './token-management.service';
@Injectable()
export class AuthService {

View File

@ -2,17 +2,7 @@ import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
type Tokens = {
access_token: string;
refresh_token: string;
};
export type TokenPayload = {
sub: string;
email: string;
iat: number;
exp: number;
};
import { TokenPayload, Tokens } from '../models/types';
@Injectable()
export class TokenManagementService {