Browse Source

feat: sync PR5458 fix

pull/5444/head
Wing-Kam Wong 2 years ago
parent
commit
100f19436e
  1. 9
      packages/nocodb-nest/src/modules/users/users.controller.ts
  2. 18
      packages/nocodb-nest/src/modules/users/users.service.ts

9
packages/nocodb-nest/src/modules/users/users.controller.ts

@ -113,6 +113,15 @@ export class UsersController {
return this.usersService.login(req.user);
}
@Post([
'/api/v1/auth/user/signout',
])
@UseGuards(AuthGuard('local'))
@HttpCode(200)
async signout(@Request() req, @Response() res) {
return this.usersService.signout({req, res});
}
@Post(`/auth/google/genTokenByCode`)
@HttpCode(200)
async googleSignin(req, res, next) {

18
packages/nocodb-nest/src/modules/users/users.service.ts

@ -481,4 +481,22 @@ export class UsersService {
token: genJwt(user, Noco.getConfig()), //this.jwtService.sign(payload),
};
}
async signout(param: {
req: any,
res: any,
}) {
try {
param.res.clearCookie('refresh_token');
const user = (param.req as any).user;
if (user) {
await User.update(user.id, {
refresh_token: null,
});
}
return { msg: 'Signed out successfully' };
} catch (e) {
NcError.badRequest(e.message);
}
}
}

Loading…
Cancel
Save