Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Juiced66 committed Oct 31, 2024
1 parent 4423b70 commit 899d6e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 12 additions & 8 deletions lib/core/security/tokenRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,20 +363,24 @@ export class TokenRepository extends ObjectRepository<Token> {

if (isApiKey) {
const fingerprint = sha256(token);

const userApiKeys = await ApiKey.search({ query : {
term: {
userId: decoded._id,

const userApiKeys = await ApiKey.search({
query: {
term: {
userId: decoded._id,
},
},
} });
});

if (userApiKeys.length === 0) {
throw securityError.get("invalid");
}

const targetApiKey = userApiKeys.find((apiKey) => apiKey.fingerprint === fingerprint);

if(!targetApiKey) {
const targetApiKey = userApiKeys.find(
(apiKey) => apiKey.fingerprint === fingerprint,
);

if (!targetApiKey) {
throw securityError.get("invalid");
}

Expand Down
3 changes: 1 addition & 2 deletions lib/model/storage/apiKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class ApiKey extends BaseModel {
},
apiKeyId || fingerprint,
);
console.log(apiKey)
await apiKey.save({ refresh, userId: creatorId });

apiKey.token = token.jwt;
Expand All @@ -139,7 +138,7 @@ class ApiKey extends BaseModel {

return apiKey;
}

/**
* Deletes API keys for an user
*
Expand Down

0 comments on commit 899d6e2

Please sign in to comment.