Spaces:
Sleeping
Sleeping
Download backend/src/modules/auth/auth.controller.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/auth/auth.controller.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/auth/auth.controller.ts
-
curl -L -o auth.controller.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/auth/auth.controller.ts
2.37 kB
| import { | |
| Controller, | |
| Post, | |
| Get, | |
| Body, | |
| Param, | |
| Query, | |
| UseGuards, | |
| Req, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; | |
| import { AuthService } from './auth.service'; | |
| import { SignupDto } from './dto/signup.dto'; | |
| import { | |
| LoginDto, | |
| ForgotPasswordDto, | |
| ResetPasswordDto, | |
| RefreshTokenDto, | |
| } from './dto/login.dto'; | |
| import { JwtAuthGuard } from './jwt-auth.guard'; | |
| ('Authentication') | |
| ('auth') | |
| export class AuthController { | |
| constructor(private readonly authService: AuthService) {} | |
| ('signup') | |
| ({ summary: 'Register a new user account' }) | |
| signup(() dto: SignupDto) { | |
| return this.authService.signup(dto); | |
| } | |
| ('login') | |
| ({ summary: 'Authenticate user & return JWT tokens' }) | |
| login(() dto: LoginDto) { | |
| return this.authService.login(dto); | |
| } | |
| ('logout') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Revoke active refresh token session' }) | |
| logout(() req: any) { | |
| return this.authService.logout(req.user.userId, req.user.sessionId); | |
| } | |
| ('refresh-token') | |
| ({ summary: 'Exchange valid refresh token for access token' }) | |
| refreshToken(() dto: RefreshTokenDto) { | |
| return this.authService.refreshToken(dto.refresh_token); | |
| } | |
| ('forgot-password') | |
| ({ summary: 'Request password-reset link' }) | |
| forgotPassword(() dto: ForgotPasswordDto) { | |
| return this.authService.forgotPassword(dto.email); | |
| } | |
| ('reset-password') | |
| ({ summary: 'Reset password using token' }) | |
| resetPassword(() dto: ResetPasswordDto) { | |
| return this.authService.resetPassword(dto.reset_token, dto.new_password); | |
| } | |
| ('oauth/:provider') | |
| ({ summary: 'Initiate OAuth provider login' }) | |
| getOAuthUrl(('provider') provider: string) { | |
| return this.authService.getOAuthUrl(provider); | |
| } | |
| ('oauth/callback') | |
| ({ summary: 'OAuth redirect callback handler' }) | |
| handleOAuthCallback(('code') code: string) { | |
| return this.authService.getOAuthUrl('callback'); | |
| } | |
| ('me') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Get current authenticated profile' }) | |
| getMe(() req: any) { | |
| return this.authService.getMe(req.user.userId); | |
| } | |
| } | |