Correction d'un bug qui ne mettait pas à jour le statut lorsque l'on quittait et revenait se connecter sur le site
This commit is contained in:
@@ -5,6 +5,7 @@ import { Response } from 'express';
|
||||
import { TwoFaDto } from './dto/2fa.dto';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { STATUS } from 'src/common/constants/constants';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthenticationController {
|
||||
@@ -36,6 +37,7 @@ export class AuthenticationController {
|
||||
console.log('On redirige');
|
||||
const user : User = request.user
|
||||
if (user.isEnabledTwoFactorAuth === false || user.isTwoFactorAuthenticated === true){
|
||||
this.userService.updateStatus(user.id, STATUS.CONNECTED)
|
||||
console.log('ON VA VERS PROFILE');
|
||||
return response.status(200).redirect('http://' + process.env.WEBSITE_HOST + ':' + process.env.WEBSITE_PORT + '/#/profile');
|
||||
}
|
||||
@@ -51,7 +53,7 @@ export class AuthenticationController {
|
||||
@UseGuards(AuthenticateGuard)
|
||||
logout(@Req() request, @Res() response, @Next() next) {
|
||||
this.userService.setIsTwoFactorAuthenticatedWhenLogout(request.user.id);
|
||||
this.userService.updateStatus(request.user.id, 'disconnected');
|
||||
this.userService.updateStatus(request.user.id, STATUS.DISCONNECTED);
|
||||
request.logout(function(err) {
|
||||
if (err) { return next(err); }
|
||||
response.redirect('/');
|
||||
@@ -83,6 +85,7 @@ export class AuthenticationController {
|
||||
throw new UnauthorizedException('Wrong Code.');
|
||||
await this.userService.authenticateUserWith2FA(request.user.id);
|
||||
console.log('ON REDIRIGE');
|
||||
this.userService.updateStatus(user.id, STATUS.CONNECTED)
|
||||
return response.status(200).redirect('http://' + process.env.WEBSITE_HOST + ':' + process.env.WEBSITE_PORT + '/#/profile');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user