Skip to content

Commit

Permalink
[#12] refactor: change access token generator to use config to retrie…
Browse files Browse the repository at this point in the history
…ve secret
  • Loading branch information
glemenneo committed Sep 21, 2024
1 parent 171394d commit 023d4a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/user-service/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { compare, hash } from 'bcrypt'
import { Request, Response } from 'express'
import { sign, SignOptions } from 'jsonwebtoken'
import { IVerifyOptions } from 'passport-local'
import config from '../common/config.util'
import { findOneUserByEmail, findOneUserByUsername } from '../models/user.repository'
import { IAccessTokenPayload } from '../types/IAccessTokenPayload'
import { Role } from '../types/Role'
Expand Down Expand Up @@ -53,7 +54,7 @@ export async function generateAccessToken(user: UserDto): Promise<string> {
audience: 'frontend',
}

const privateKey: Buffer = Buffer.from(process.env.ACCESS_TOKEN_PRIVATE_KEY!, 'base64')
const privateKey: Buffer = Buffer.from(config.ACCESS_TOKEN_PRIVATE_KEY, 'base64')

return sign(payload, privateKey, options)
}
Expand Down

0 comments on commit 023d4a9

Please sign in to comment.