Skip to content

Commit 7f7a3f5

Browse files
authored
Merge pull request #405 from rabsqueen/centralized-logging
Centralized logging system and core modules implementation
2 parents b55b48c + d8bb612 commit 7f7a3f5

25 files changed

Lines changed: 622 additions & 0 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
createParamDecorator,
3+
ExecutionContext,
4+
} from '@nestjs/common';
5+
6+
export const CurrentUser =
7+
createParamDecorator(
8+
(
9+
_data: unknown,
10+
ctx: ExecutionContext,
11+
) => {
12+
const request = ctx
13+
.switchToHttp()
14+
.getRequest();
15+
16+
return request.user;
17+
},
18+
);

src/auth/dto/login.dto.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {
2+
IsEmail,
3+
IsString,
4+
MinLength,
5+
} from 'class-validator';
6+
7+
export class LoginDto {
8+
@IsEmail()
9+
email: string;
10+
11+
@IsString()
12+
@MinLength(8)
13+
password: string;
14+
}

src/auth/dto/oauth-callback.dto.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { IsString } from 'class-validator';
2+
3+
export class OAuthCallbackDto {
4+
@IsString()
5+
code: string;
6+
7+
@IsString()
8+
state: string;
9+
}

src/auth/dto/refresh-token.dto.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {
2+
IsString,
3+
MinLength,
4+
} from 'class-validator';
5+
6+
export class RefreshTokenDto {
7+
@IsString()
8+
@MinLength(20)
9+
refreshToken: string;
10+
}

src/auth/dto/register.dto.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {
2+
IsEmail,
3+
IsString,
4+
MinLength,
5+
} from 'class-validator';
6+
7+
export class RegisterDto {
8+
@IsEmail()
9+
email: string;
10+
11+
@IsString()
12+
@MinLength(2)
13+
firstName: string;
14+
15+
@IsString()
16+
@MinLength(2)
17+
lastName: string;
18+
19+
@IsString()
20+
@MinLength(8)
21+
password: string;
22+
}

src/auth/dto/verify-mfa.dto.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {
2+
IsString,
3+
Length,
4+
} from 'class-validator';
5+
6+
export class VerifyMfaDto {
7+
@IsString()
8+
@Length(6, 6)
9+
code: string;
10+
}

src/auth/guards/mfa.guard.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
CanActivate,
3+
ExecutionContext,
4+
Injectable,
5+
} from '@nestjs/common';
6+
7+
@Injectable()
8+
export class MfaGuard
9+
implements CanActivate
10+
{
11+
canActivate(
12+
_context: ExecutionContext,
13+
): boolean {
14+
return true;
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
CanActivate,
3+
ExecutionContext,
4+
Injectable,
5+
} from '@nestjs/common';
6+
7+
@Injectable()
8+
export class RefreshTokenGuard
9+
implements CanActivate
10+
{
11+
canActivate(
12+
_context: ExecutionContext,
13+
): boolean {
14+
return true;
15+
}
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface OAuthProfile {
2+
provider: string;
3+
providerId: string;
4+
email: string;
5+
firstName?: string;
6+
lastName?: string;
7+
avatarUrl?: string;
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface Session {
2+
id: string;
3+
userId: string;
4+
deviceId: string;
5+
ipAddress: string;
6+
userAgent: string;
7+
createdAt: Date;
8+
expiresAt: Date;
9+
}

0 commit comments

Comments
 (0)