-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from ldhbenecia/feature/mogaco
[Feat] 모각코 로그인 권한 처리 및 API Response 카멜케이스 처리
- Loading branch information
Showing
22 changed files
with
120 additions
and
197 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { ExecutionContext, createParamDecorator } from '@nestjs/common'; | ||
import { Member } from '@prisma/client'; | ||
|
||
export const GetUser = createParamDecorator((data: unknown, ctx: ExecutionContext) => { | ||
export const GetUser = createParamDecorator((data: unknown, ctx: ExecutionContext): Member => { | ||
const request = ctx.switchToHttp().getRequest(); | ||
return request.user; | ||
}); |
13 changes: 0 additions & 13 deletions
13
app/backend/prisma/migrations/20231111101044_init/migration.sql
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
app/backend/prisma/migrations/20231121023456_init/migration.sql
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
app/backend/prisma/migrations/20231121023509_morak_0_0_1/migration.sql
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/backend/prisma/migrations/20231121065729_init/migration.sql
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
app/backend/prisma/migrations/20231121065750_morak_0_0_2/migration.sql
This file was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,28 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Injectable, UnauthorizedException } from '@nestjs/common'; | ||
import { PassportStrategy } from '@nestjs/passport'; | ||
import { ExtractJwt, Strategy } from 'passport-jwt'; | ||
import { Payload } from '../interface'; | ||
import { getSecret } from 'vault'; | ||
import { Member } from '@prisma/client'; | ||
import { AuthRepository } from '../auth.repository'; | ||
|
||
@Injectable() | ||
export class AtStrategy extends PassportStrategy(Strategy, 'jwt') { | ||
constructor() { | ||
constructor(private authRepository: AuthRepository) { | ||
super({ | ||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), | ||
secretOrKey: getSecret('JWT_ACCESS_SECRET'), | ||
}); | ||
} | ||
|
||
async validate(payload: Payload) { | ||
return payload; | ||
const { providerId } = payload; | ||
const member: Member = await this.authRepository.findUserByIdentifier(providerId); | ||
|
||
if (!member) { | ||
throw new UnauthorizedException(); | ||
} | ||
|
||
return member; | ||
} | ||
} |
Oops, something went wrong.