feat: add get profile endpoint

This commit is contained in:
caturbgs 2021-12-14 21:16:28 +07:00
parent 3835b0ee35
commit b4cd5620e5
2 changed files with 7 additions and 5 deletions

View File

@ -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 { LocalAuthGuard } from './local-auth.guard';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import { JwtAuthGuard } from './jwt-auth.guard'; import { Public } from './public.decorator';
import {Public} from "./public.decorator";
@Controller({ @Controller({
path: 'auth', path: 'auth',
@ -18,9 +17,8 @@ export class AuthController {
return this.authService.login(req.user); return this.authService.login(req.user);
} }
@UseGuards(JwtAuthGuard)
@Get('profile') @Get('profile')
getProfile(@Request() req) { getProfile(@Request() req) {
return req.user; return this.authService.getProfile(req.user.userId);
} }
} }

View File

@ -35,4 +35,8 @@ export class AuthService {
access_token: this.jwtService.sign(payload), access_token: this.jwtService.sign(payload),
}; };
} }
getProfile = async (userId: string) => {
return this.usersService.findOne(userId);
};
} }