style(credentials): correct syntax and improve formatting in CredentialsService
This commit corrects a minor syntax error by adding missing semicolons on two lines. It also tidies up code by improving the formatting in the constructor and function signAuthToken.
This commit is contained in:
parent
f681dd77bd
commit
5a5a8c1114
@ -2,13 +2,11 @@ import { BadRequestException, Injectable } from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import * as argon from "argon2";
|
||||
import * as jose from "jose";
|
||||
import { generateSecret, JWTPayload } from "jose";
|
||||
import { JWTPayload, generateSecret } from "jose";
|
||||
|
||||
@Injectable()
|
||||
export class CredentialsService {
|
||||
constructor(
|
||||
private readonly configService: ConfigService,
|
||||
) {}
|
||||
constructor(private readonly configService: ConfigService) {}
|
||||
|
||||
async hash(plaintextPassword: string) {
|
||||
console.log(plaintextPassword);
|
||||
@ -36,14 +34,16 @@ export class CredentialsService {
|
||||
}
|
||||
|
||||
async signAuthToken(payload: JWTPayload) {
|
||||
console.log(this.configService.get("APP_TOKEN_SECRET"))
|
||||
console.log(this.configService.get("APP_TOKEN_SECRET"));
|
||||
const token = new jose.SignJWT(payload)
|
||||
.setProtectedHeader({ alg: "HS512", enc: "A128CBC-HS512" })
|
||||
.setIssuedAt()
|
||||
.setExpirationTime("3 day")
|
||||
.setIssuer("ShouldStick")
|
||||
.setAudience("auth:user")
|
||||
console.log(token)
|
||||
return await token.sign(Uint8Array.from(this.configService.get("APP_TOKEN_SECRET")));
|
||||
.setAudience("auth:user");
|
||||
console.log(token);
|
||||
return await token.sign(
|
||||
Uint8Array.from(this.configService.get("APP_TOKEN_SECRET")),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user