Skip to content

Naming of functions generating JWT, and consistency of data associated with JWT #3

@polymorpher

Description

@polymorpher

In

async getTokens(payload: object) {
, the function is named as a get-only function (i.e. pure), but in fact it mutates the server state, generate and records a JWT token at the server (via jwtService.signAsync). The name should be updated to reflect that, e.g. create...

In

const userData = this.jwtService.verify(body.token);
, a new token is generated using returned userData with a few JWT fields deleted. This can be potentially inconsistent with the payload given in other places, such as
const jwt = await this.userService.getTokens(payload)
. It could lead to error if new fields are added later one, or if library updates and assigns new fields to the payload

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions