Skip to content

Commit

Permalink
Merge pull request #26 from fga-eps-mds/fix#112/change-jwt
Browse files Browse the repository at this point in the history
[FIX] Adiciona atributo ID ao JWT (fga-eps-mds/2024.2-ARANDU-DOC#112)
  • Loading branch information
dartmol203 authored Jan 12, 2025
2 parents 5e1c347 + 936f77f commit 5b0c4d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ export class AuthService {
async login(user: any) {
const tokens = await this.generateTokens({
userId: user._id,
id: user._id,
name: user.name,
email: user.email,
role: user.role,
});
return {
userId: user._id,
id: user._id,
name: user.name,
email: user.email,
...tokens,
Expand All @@ -76,6 +77,7 @@ export class AuthService {
}
const token = await this.generateTokens({
userId: user._id,
id: user._id,
name: user.name,
email: user.email,
role: user.role,
Expand All @@ -84,9 +86,10 @@ export class AuthService {
return { user, token };
}

async generateTokens({ userId, name, email, role }) {
async generateTokens({ userId, id, name, email, role }) {
const payload = {
userId: userId,
id: id,
name: name,
email: email,
sub: userId,
Expand Down Expand Up @@ -143,6 +146,7 @@ export class AuthService {

return this.generateTokens({
userId: user._id,
id: user._id,
name: user.name,
email: user.email,
role: user.role,
Expand Down

0 comments on commit 5b0c4d1

Please sign in to comment.