add: role in jwt
This commit is contained in:
@@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import { UsersService } from '../users/users.service';
|
||||
import { hashPassword } from '../helper/hash_password';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@@ -22,10 +23,11 @@ export class AuthService {
|
||||
return null;
|
||||
}
|
||||
|
||||
async login(user: any) {
|
||||
async login(user: User) {
|
||||
const payload = {
|
||||
username: user.username,
|
||||
sub: user.userId,
|
||||
sub: user.id,
|
||||
role: user.roles.name,
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user