WIP - fix browser refresh not holding user authentication
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Get,
|
||||
Body,
|
||||
UnauthorizedException,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { IsEmail, IsString, MinLength, IsOptional } from 'class-validator';
|
||||
import { AuthService } from './auth.service';
|
||||
import { TenantId } from '../tenant/tenant.decorator';
|
||||
import { JwtAuthGuard } from './jwt-auth.guard';
|
||||
import { CurrentUser } from './current-user.decorator';
|
||||
|
||||
class LoginDto {
|
||||
@IsEmail()
|
||||
@@ -111,4 +115,15 @@ export class AuthController {
|
||||
// This endpoint exists for consistency and potential future enhancements
|
||||
return { message: 'Logged out successfully' };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('me')
|
||||
async me(@CurrentUser() user: any, @TenantId() tenantId: string) {
|
||||
// Return the current authenticated user info
|
||||
return {
|
||||
id: user.userId,
|
||||
email: user.email,
|
||||
tenantId: tenantId || user.tenantId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user