feat: add get profile endpoint
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { Controller, Post, UseGuards, Request, Get } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Request, UseGuards } from '@nestjs/common';
|
||||
import { LocalAuthGuard } from './local-auth.guard';
|
||||
import { AuthService } from './auth.service';
|
||||
import { JwtAuthGuard } from './jwt-auth.guard';
|
||||
import {Public} from "./public.decorator";
|
||||
import { Public } from './public.decorator';
|
||||
|
||||
@Controller({
|
||||
path: 'auth',
|
||||
@@ -18,9 +17,8 @@ export class AuthController {
|
||||
return this.authService.login(req.user);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('profile')
|
||||
getProfile(@Request() req) {
|
||||
return req.user;
|
||||
return this.authService.getProfile(req.user.userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,8 @@ export class AuthService {
|
||||
access_token: this.jwtService.sign(payload),
|
||||
};
|
||||
}
|
||||
|
||||
getProfile = async (userId: string) => {
|
||||
return this.usersService.findOne(userId);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user