Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
arnard76 committed Apr 26, 2024
1 parent aa15f26 commit f125049
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions backend/src/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,20 @@ export default class AuthContext {
}

async login(username: string, password: string): Promise<Nullable<{ token: string; user: User }>> {
try {
await this.authServiceProvider.authenticateUser(username, password)

// no error? means auth succeeded

// update this to show additional user details
const authenticatedUser = new User({
username: username,
email: username,
displayName: "Admin",
verified: true,
registeredAt: undefined,
})

return { token: this.issueToken(username), user: authenticatedUser }
} catch (e) {
if (!(await this.authServiceProvider.authenticateUser(username, password))) {
return null
}

// update this to show additional user details
const authenticatedUser = new User({
username: username,
email: username,
displayName: "Admin",
verified: true,
registeredAt: undefined,
})

return { token: this.issueToken(username), user: authenticatedUser }
}

verifyToken(token: string): Nullable<string | JwtPayload> {
Expand Down

0 comments on commit f125049

Please sign in to comment.