|
|
|
@ -42,7 +42,7 @@ export class AuthController {
|
|
|
|
|
]) |
|
|
|
|
@UseGuards(PublicApiLimiterGuard) |
|
|
|
|
@HttpCode(200) |
|
|
|
|
async signup(@Req() req: Request, @Res() res:Response): Promise<any> { |
|
|
|
|
async signup(@Req() req: Request, @Res() res: Response): Promise<any> { |
|
|
|
|
if (this.config.get('auth', { infer: true }).disableEmailAuth) { |
|
|
|
|
NcError.forbidden('Email authentication is disabled'); |
|
|
|
|
} |
|
|
|
@ -62,7 +62,7 @@ export class AuthController {
|
|
|
|
|
]) |
|
|
|
|
@UseGuards(PublicApiLimiterGuard) |
|
|
|
|
@HttpCode(200) |
|
|
|
|
async refreshToken(@Req() req: Request, @Res() res:Response): Promise<any> { |
|
|
|
|
async refreshToken(@Req() req: Request, @Res() res: Response): Promise<any> { |
|
|
|
|
res.json( |
|
|
|
|
await this.usersService.refreshToken({ |
|
|
|
|
body: req.body, |
|
|
|
@ -79,7 +79,7 @@ export class AuthController {
|
|
|
|
|
]) |
|
|
|
|
@UseGuards(PublicApiLimiterGuard, AuthGuard('local')) |
|
|
|
|
@HttpCode(200) |
|
|
|
|
async signin(@Req() req:Request, @Res() res:Response) { |
|
|
|
|
async signin(@Req() req: Request, @Res() res: Response) { |
|
|
|
|
if (this.config.get('auth', { infer: true }).disableEmailAuth) { |
|
|
|
|
NcError.forbidden('Email authentication is disabled'); |
|
|
|
|
} |
|
|
|
@ -90,7 +90,7 @@ export class AuthController {
|
|
|
|
|
@UseGuards(GlobalGuard) |
|
|
|
|
@Post('/api/v1/auth/user/signout') |
|
|
|
|
@HttpCode(200) |
|
|
|
|
async signOut(@Req() req:Request, @Res() res:Response): Promise<any> { |
|
|
|
|
async signOut(@Req() req: Request, @Res() res: Response): Promise<any> { |
|
|
|
|
if (!(req as any).isAuthenticated()) { |
|
|
|
|
NcError.forbidden('Not allowed'); |
|
|
|
|
} |
|
|
|
@ -105,7 +105,7 @@ export class AuthController {
|
|
|
|
|
@Post(`/auth/google/genTokenByCode`) |
|
|
|
|
@HttpCode(200) |
|
|
|
|
@UseGuards(PublicApiLimiterGuard, AuthGuard('google')) |
|
|
|
|
async googleSignin(@Req() req:Request, @Res() res:Response) { |
|
|
|
|
async googleSignin(@Req() req: Request, @Res() res: Response) { |
|
|
|
|
await this.setRefreshToken({ req, res }); |
|
|
|
|
res.json(await this.usersService.login(req.user, req)); |
|
|
|
|
} |
|
|
|
@ -118,7 +118,7 @@ export class AuthController {
|
|
|
|
|
|
|
|
|
|
@Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me']) |
|
|
|
|
@UseGuards(MetaApiLimiterGuard, GlobalGuard) |
|
|
|
|
async me(@Req() req:Request) { |
|
|
|
|
async me(@Req() req: Request) { |
|
|
|
|
const user = { |
|
|
|
|
...req.user, |
|
|
|
|
roles: extractRolesObj(req.user.roles), |
|
|
|
@ -229,7 +229,7 @@ export class AuthController {
|
|
|
|
|
@UseGuards(PublicApiLimiterGuard) |
|
|
|
|
async renderPasswordReset( |
|
|
|
|
@Req() req: Request, |
|
|
|
|
@Res() res:Response, |
|
|
|
|
@Res() res: Response, |
|
|
|
|
@Param('tokenId') tokenId: string, |
|
|
|
|
): Promise<any> { |
|
|
|
|
try { |
|
|
|
|