Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
sabhas committed Sep 21, 2022
1 parent 330c020 commit d93470d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const token = async (data: any): Promise<TokenResponse> => {

AuthController.deleteCode(userInfo.userId, clientId)

// // get tokens from DB
// get tokens from DB
const existingTokens = await getTokensFromDB(userInfo.userId, clientId)
if (existingTokens) {
return {
Expand Down
16 changes: 5 additions & 11 deletions api/src/utils/getTokensFromDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ export const getTokensFromDB = async (userId: number, clientId: string) => {
)

if (
verifiedAccessToken?.userId !== userId ||
verifiedAccessToken?.clientId !== clientId
verifiedAccessToken?.userId === userId &&
verifiedAccessToken?.clientId === clientId &&
verifiedRefreshToken?.userId === userId &&
verifiedRefreshToken?.clientId === clientId
)
return

if (
verifiedRefreshToken?.userId !== userId ||
verifiedRefreshToken?.clientId !== clientId
)
return

return { accessToken, refreshToken }
return { accessToken, refreshToken }
}
}

0 comments on commit d93470d

Please sign in to comment.