@@ -49,6 +49,7 @@ import { Public } from './decorators/public.decorator';
4949import { ChangePasswordDto } from './dtos/change-password.dto' ;
5050import { ConfirmEmailDto } from './dtos/confirm-email.dto' ;
5151import { EmailDto } from './dtos/email.dto' ;
52+ import { RefreshAccessDto } from './dtos/refresh-access.dto' ;
5253import { ResetPasswordDto } from './dtos/reset-password.dto' ;
5354import { SignInDto } from './dtos/sign-in.dto' ;
5455import { SignUpDto } from './dtos/sign-up.dto' ;
@@ -136,8 +137,9 @@ export class AuthController {
136137 public async refreshAccess (
137138 @Req ( ) req : FastifyRequest ,
138139 @Res ( ) res : FastifyReply ,
140+ @Body ( ) refreshAccessDto ?: RefreshAccessDto ,
139141 ) : Promise < void > {
140- const token = this . refreshTokenFromReq ( req ) ;
142+ const token = this . refreshTokenFromReq ( req , refreshAccessDto ) ;
141143 const result = await this . authService . refreshTokenAccess (
142144 token ,
143145 req . headers . origin ,
@@ -161,8 +163,9 @@ export class AuthController {
161163 public async logout (
162164 @Req ( ) req : FastifyRequest ,
163165 @Res ( ) res : FastifyReply ,
166+ @Body ( ) refreshAccessDto ?: RefreshAccessDto ,
164167 ) : Promise < void > {
165- const token = this . refreshTokenFromReq ( req ) ;
168+ const token = this . refreshTokenFromReq ( req , refreshAccessDto ) ;
166169 const message = await this . authService . logout ( token ) ;
167170 res
168171 . clearCookie ( this . cookieName , { path : this . cookiePath } )
@@ -189,7 +192,7 @@ export class AuthController {
189192 @Body ( ) confirmEmailDto : ConfirmEmailDto ,
190193 @Res ( ) res : FastifyReply ,
191194 ) : Promise < void > {
192- const result = await this . authService . confirmEmail ( confirmEmailDto ) ;
195+ const result = await this . authService . confirmEmail ( confirmEmailDto , origin ) ;
193196 this . saveRefreshCookie ( res , result . refreshToken )
194197 . status ( HttpStatus . OK )
195198 . send ( AuthResponseMapper . map ( result ) ) ;
@@ -279,10 +282,17 @@ export class AuthController {
279282 return OAuthProvidersResponseMapper . map ( providers ) ;
280283 }
281284
282- private refreshTokenFromReq ( req : FastifyRequest ) : string {
285+ private refreshTokenFromReq (
286+ req : FastifyRequest ,
287+ dto ?: RefreshAccessDto ,
288+ ) : string {
283289 const token : string | undefined = req . cookies [ this . cookieName ] ;
284290
285291 if ( isUndefined ( token ) || isNull ( token ) ) {
292+ if ( ! isUndefined ( dto ?. refreshToken ) ) {
293+ return dto . refreshToken ;
294+ }
295+
286296 throw new UnauthorizedException ( ) ;
287297 }
288298
0 commit comments