File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
apps/api/src/modules/auth
libs/repository/src/entities Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 signInToCookie ,
1414} from './common/auth.model' ;
1515import { JwtUserRefreshGuard } from './guards/jwt-user-refresh.guard' ;
16+ import { JwtUserGuard } from './guards/jwt-user.guard' ;
1617
1718@Controller ( '/api/auth' )
1819export class AuthController {
@@ -32,6 +33,14 @@ export class AuthController {
3233 return makeResponse ( await this . authService . signIn ( body ) , signInToBody , signInToCookie ) ;
3334 }
3435
36+ @Post ( '/sign-out' )
37+ @UseValidationPipe ( )
38+ @UseGuards ( JwtUserGuard )
39+ @Transactional ( )
40+ async signOut ( @User ( ) user : ContextUser ) {
41+ return makeResponse ( await this . authService . signOut ( user . id ) , identity ) ;
42+ }
43+
3544 @Post ( '/confirm-email' )
3645 @UseValidationPipe ( )
3746 @Transactional ( )
Original file line number Diff line number Diff line change @@ -59,10 +59,10 @@ export class AuthService {
5959 } ;
6060 }
6161
62- async signOut ( email : string ) {
63- const user = await this . rep . user . findOne ( { where : { email } } ) ;
62+ async signOut ( id : number ) {
63+ const user = await this . rep . user . findOne ( { where : { id } } ) ;
6464 if ( user ) {
65- user . refreshTokenHash = undefined ;
65+ user . refreshTokenHash = null ;
6666 await this . rep . user . save ( user ) ;
6767 }
6868 }
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ export class UserEntity {
1717 @Column ( { default : false } )
1818 emailConfirmed : boolean ;
1919
20- @Column ( { nullable : true } )
21- refreshTokenHash ?: string ;
20+ @Column ( { type : 'text' , nullable : true } )
21+ refreshTokenHash ?: string | null ;
2222
23- @Column ( { nullable : true } )
24- emailConfirmToken ?: string ;
23+ @Column ( { type : 'text' , nullable : true } )
24+ emailConfirmToken ?: string | null ;
2525}
You can’t perform that action at this time.
0 commit comments