feat: add get profile endpoint
This commit is contained in:
parent
3835b0ee35
commit
b4cd5620e5
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user