Skip to content

Add API key suspended message and format code in AuthWithApiMiddleware#1541

Merged
Artuomka merged 1 commit into
mainfrom
backend_ai_table_settings_fix
Jan 28, 2026
Merged

Add API key suspended message and format code in AuthWithApiMiddleware#1541
Artuomka merged 1 commit into
mainfrom
backend_ai_table_settings_fix

Conversation

@Artuomka

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 28, 2026 16:36
@Artuomka Artuomka merged commit ba9de5e into main Jan 28, 2026
15 checks passed
@Artuomka Artuomka deleted the backend_ai_table_settings_fix branch January 28, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds handling for suspended user accounts when authenticating with API keys and converts the auth-with-api.middleware.ts file to use tab indentation (consistent with the project's Biome formatter configuration).

Changes:

  • Added API_KEY_SUSPENDED error message constant
  • Added logic to check if a user account is suspended during API key authentication
  • Reformatted auth-with-api.middleware.ts from 2-space to tab indentation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
backend/src/exceptions/text/messages.ts Added new API_KEY_SUSPENDED error message constant for suspended user accounts
backend/src/authorization/auth-with-api.middleware.ts Added suspended user check in API key authentication flow and reformatted code to use tab indentation per biome.json config

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +107 to +113
if (foundUserByApiKey.suspended) {
throw new UnauthorizedException(Messages.API_KEY_SUSPENDED);
}

if (!foundUserByApiKey) {
throw new NotFoundException(Messages.NO_AUTH_KEYS_FOUND);
}

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null check for foundUserByApiKey must be performed before accessing its suspended property. Currently, if no user is found with the provided API key, the code will throw a runtime error when trying to access .suspended on a null object at line 107. The null check on lines 111-113 should be moved before the suspended check on lines 107-109.

Suggested change
if (foundUserByApiKey.suspended) {
throw new UnauthorizedException(Messages.API_KEY_SUSPENDED);
}
if (!foundUserByApiKey) {
throw new NotFoundException(Messages.NO_AUTH_KEYS_FOUND);
}
if (!foundUserByApiKey) {
throw new NotFoundException(Messages.NO_AUTH_KEYS_FOUND);
}
if (foundUserByApiKey.suspended) {
throw new UnauthorizedException(Messages.API_KEY_SUSPENDED);
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants