generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
590a2fb
commit 7f22dec
Showing
26 changed files
with
136 additions
and
193 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
backend/src/modules/auth/applications/create-reset-token.auth.application.ts
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
...rvices/create-reset-token.auth.service.ts → ...plications/create-reset-token.use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
backend/src/modules/auth/applications/get-token.auth.application.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
backend/src/modules/auth/applications/refresh-token.use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { RefreshTokenUseCaseInterface } from '../interfaces/applications/refresh-token.use-case.interface'; | ||
import { TYPES } from '../interfaces/types'; | ||
import { GetTokenAuthServiceInterface } from '../interfaces/services/get-token.auth.service.interface'; | ||
|
||
@Injectable() | ||
export default class RefreshTokenUseCase implements RefreshTokenUseCaseInterface { | ||
constructor( | ||
@Inject(TYPES.services.GetTokenAuthService) | ||
private readonly getTokenService: GetTokenAuthServiceInterface | ||
) {} | ||
|
||
async execute(userId: string) { | ||
return this.getTokenService.getAccessToken(userId); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
backend/src/modules/auth/applications/reset-password.use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { BadRequestException, Inject, Injectable, UnauthorizedException } from '@nestjs/common'; | ||
import { TYPES } from 'src/modules/users/interfaces/types'; | ||
import { ResetPasswordUseCaseInterface } from '../interfaces/applications/reset-password.use-case.interface'; | ||
import { UpdateUserServiceInterface } from 'src/modules/users/interfaces/services/update.user.service.interface'; | ||
import { UPDATE_FAILED } from 'src/libs/exceptions/messages'; | ||
|
||
@Injectable() | ||
export default class ResetPasswordUseCase implements ResetPasswordUseCaseInterface { | ||
constructor( | ||
@Inject(TYPES.services.UpdateUserService) | ||
private readonly updateUserService: UpdateUserServiceInterface | ||
) {} | ||
|
||
async execute(token: string, newPassword: string, newPasswordConf: string) { | ||
const email = await this.updateUserService.checkEmailOfToken(token); | ||
|
||
if (!email) { | ||
throw new UnauthorizedException('Invalid token!'); | ||
} | ||
|
||
const result = await this.updateUserService.setPassword(email, newPassword, newPasswordConf); | ||
|
||
if (!result) { | ||
throw new BadRequestException(UPDATE_FAILED); | ||
} | ||
|
||
return { | ||
status: 'ok', | ||
message: 'Password updated successfully!' | ||
}; | ||
} | ||
} |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
backend/src/modules/auth/applications/validate-user-email.use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
...src/modules/auth/interfaces/applications/create-reset-token.auth.application.interface.ts
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
backend/src/modules/auth/interfaces/applications/create-reset-token.use-case.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface CreateResetTokenUseCaseInterface { | ||
execute(emailAddress: string): Promise<{ | ||
message: string; | ||
}>; | ||
} |
Oops, something went wrong.