Skip to content

Commit

Permalink
update api key verification so return spelling mistake prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
AdenForshaw committed Nov 1, 2024
1 parent d9baf07 commit 2ade545
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/gcs/gcs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class GcsService {

constructor() {

if(!process.env.BIGQUERY_PROJECT_ID || !process.env.GOOGLE_APPLICATION_CREDENTIALS || !process.env.GCS_BUCKET_NAME){
if(!process.env.GCS_BUCKET_NAME){
this.logger.error('GCS environment variables not set');
return;
}
Expand Down
28 changes: 13 additions & 15 deletions src/middleware/auth-api.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,22 @@ export class AuthAPIMiddleware implements NestMiddleware {
}

try {
if(!this.theAuthAPI) {
Logger.error('APIKeyMiddleware Error: Auth API not initialized');
if(this.theAuthAPI) {

const apiKey = await this.theAuthAPI.apiKeys.authenticateKey(apiKeyString);
if (apiKey) {
const userObj = {
metadata: apiKey.customMetaData,
accountId: apiKey.customAccountId,
userId: apiKey.customUserId,
};

//set to both req and locals for backwards compatibility
req['user'] = req.res.locals['user'] = userObj;
}
next();
return;
}
const apiKey = await this.theAuthAPI.apiKeys.authenticateKey(apiKeyString);
if (apiKey) {
const userObj = {
metadata: apiKey.customMetaData,
accountId: apiKey.customAccountId,
userId: apiKey.customUserId,
};

//set to both req and locals for backwards compatibility
req['user'] = req.res.locals['user'] = userObj;
}
next();
return;
} catch (error) {
Logger.error('APIKeyMiddleware Error:', error, ` key: ${apiKeyString}`);
}
Expand Down

0 comments on commit 2ade545

Please sign in to comment.