Feature disable password login #378

Merged
LukeGus merged 6 commits from feature-disable-password-login into dev-1.8.0 2025-10-08 00:59:44 +00:00
LukeGus commented 2025-10-08 00:51:26 +00:00 (Migrated from github.com)

Overview

Short summary of what this PR does

  • Added: ...
  • Updated: ...
  • Removed: ...
  • Fixed: ...

Changes Made

Detailed explanation of changes (if needed)

  • ...

Related Issues

Link any issues this PR addresses

  • Closes #ISSUE_NUMBER
  • Related to #ISSUE_NUMBER

Screenshots / Demos

(Optional: add before/after screenshots, GIFs, or console output)

Checklist

  • Code follows project style guidelines
  • Supports mobile and desktop UI/app (if applicable)
  • I have read Contributing.md
# Overview _Short summary of what this PR does_ - [ ] Added: ... - [ ] Updated: ... - [ ] Removed: ... - [ ] Fixed: ... # Changes Made _Detailed explanation of changes (if needed)_ - ... # Related Issues _Link any issues this PR addresses_ - Closes #ISSUE_NUMBER - Related to #ISSUE_NUMBER # Screenshots / Demos _(Optional: add before/after screenshots, GIFs, or console output)_ # Checklist - [ ] Code follows project style guidelines - [ ] Supports mobile and desktop UI/app (if applicable) - [ ] I have read [Contributing.md](https://github.com/LukeGus/Termix/blob/main/CONTRIBUTING.md)
gemini-code-assist[bot] commented 2025-10-08 00:51:45 +00:00 (Migrated from github.com)

Summary of Changes

Hello @LukeGus, I'm Gemini Code Assist1 ! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on bolstering the application's security and improving user experience in the File Manager. It introduces a new feature allowing administrators to toggle password login functionality, providing greater flexibility in authentication methods. Concurrently, the backend's field encryption mechanism has been refined to ensure robust and consistent handling of sensitive data regardless of naming conventions. Additionally, the File Manager now presents clearer and more informative confirmation dialogues for file deletion, helping users prevent accidental data loss.

Highlights

  • Password Login Control: Introduced an administrative setting to enable or disable password-based login, enhancing security configuration options.
  • Field Encryption Enhancement: Updated backend encryption logic to consistently handle both snake_case and camelCase field names for sensitive data across various entities.
  • Improved File Deletion Confirmations: Enhanced the File Manager with more explicit and context-specific confirmation prompts for deleting files and folders, including warnings about permanent deletion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩︎

## Summary of Changes Hello @LukeGus, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on bolstering the application's security and improving user experience in the File Manager. It introduces a new feature allowing administrators to toggle password login functionality, providing greater flexibility in authentication methods. Concurrently, the backend's field encryption mechanism has been refined to ensure robust and consistent handling of sensitive data regardless of naming conventions. Additionally, the File Manager now presents clearer and more informative confirmation dialogues for file deletion, helping users prevent accidental data loss. ### Highlights * **Password Login Control**: Introduced an administrative setting to enable or disable password-based login, enhancing security configuration options. * **Field Encryption Enhancement**: Updated backend encryption logic to consistently handle both snake_case and camelCase field names for sensitive data across various entities. * **Improved File Deletion Confirmations**: Enhanced the File Manager with more explicit and context-specific confirmation prompts for deleting files and folders, including warnings about permanent deletion. <details> <summary><b>Using Gemini Code Assist</b></summary> <br> The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips. <b>Invoking Gemini</b> You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page. Feature | Command | Description --- | --- | --- Code Review | `/gemini review` | Performs a code review for the current pull request in its current state. Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state. Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. Help | `/gemini help` | Displays a list of available commands. <b>Customization</b> To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). <b>Limitations & Feedback</b> Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG). <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b> </details> [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
gemini-code-assist[bot] (Migrated from github.com) reviewed 2025-10-08 00:53:38 +00:00
gemini-code-assist[bot] (Migrated from github.com) left a comment

Code Review

This pull request introduces a feature to disable password-based login, adding a new setting and the corresponding backend and frontend components to manage it. My review focuses on improving security, maintainability, and type safety. I've identified a "fail-open" security issue in the login flow, suggested using existing middleware to reduce code duplication, recommended stricter typing to avoid any, and proposed making error handling more robust by using error codes instead of string matching. These changes will enhance the security and maintainability of the new feature.

## Code Review This pull request introduces a feature to disable password-based login, adding a new setting and the corresponding backend and frontend components to manage it. My review focuses on improving security, maintainability, and type safety. I've identified a "fail-open" security issue in the login flow, suggested using existing middleware to reduce code duplication, recommended stricter typing to avoid `any`, and proposed making error handling more robust by using error codes instead of string matching. These changes will enhance the security and maintainability of the new feature.
@@ -848,6 +848,23 @@ router.post("/login", async (req, res) => {
return res.status(400).json({ error: "Invalid username or password" });
gemini-code-assist[bot] (Migrated from github.com) commented 2025-10-08 00:53:37 +00:00

high

The current implementation has a "fail-open" vulnerability. If the database query to check allow_password_login fails, the catch block only logs a warning and allows the login process to continue. This could unintentionally permit password logins even when they are supposed to be disabled. The login attempt should be aborted if this check fails.

  } catch (e) {
    authLogger.error("Failed to check password login status", {
      operation: "login_check",
      error: e,
    });
    return res.status(500).json({ error: "Failed to check login status" });
  }
![high](https://www.gstatic.com/codereviewagent/high-priority.svg) The current implementation has a "fail-open" vulnerability. If the database query to check `allow_password_login` fails, the `catch` block only logs a warning and allows the login process to continue. This could unintentionally permit password logins even when they are supposed to be disabled. The login attempt should be aborted if this check fails. ```suggestion } catch (e) { authLogger.error("Failed to check password login status", { operation: "login_check", error: e, }); return res.status(500).json({ error: "Failed to check login status" }); } ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-10-08 00:53:38 +00:00

medium

Using as any bypasses TypeScript's type checking and can lead to runtime errors if the data structure changes. Since you are querying the settings table, you can expect row to be an object with a value property of type string. Casting to a more specific type improves type safety.

    if (row && (row as { value: string }).value !== "true") {
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) Using `as any` bypasses TypeScript's type checking and can lead to runtime errors if the data structure changes. Since you are querying the `settings` table, you can expect `row` to be an object with a `value` property of type `string`. Casting to a more specific type improves type safety. ```suggestion if (row && (row as { value: string }).value !== "true") { ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-10-08 00:53:38 +00:00

medium

Using as any is not type-safe. It's better to cast to a more specific type like { value: string } to leverage TypeScript's type checking and prevent potential runtime errors.

    res.json({ allowed: row ? (row as { value: string }).value === "true" : true });
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) Using `as any` is not type-safe. It's better to cast to a more specific type like `{ value: string }` to leverage TypeScript's type checking and prevent potential runtime errors. ```suggestion res.json({ allowed: row ? (row as { value: string }).value === "true" : true }); ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-10-08 00:53:38 +00:00

medium

This route manually checks for admin privileges, but there is an existing requireAdmin middleware that encapsulates this logic. Using the dedicated middleware would reduce code duplication and improve maintainability by centralizing the authorization check. The userId variable is also unused in this route and can be removed.

router.patch("/password-login-allowed", requireAdmin, async (req, res) => {
  try {
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) This route manually checks for admin privileges, but there is an existing `requireAdmin` middleware that encapsulates this logic. Using the dedicated middleware would reduce code duplication and improve maintainability by centralizing the authorization check. The `userId` variable is also unused in this route and can be removed. ```typescript router.patch("/password-login-allowed", requireAdmin, async (req, res) => { try { ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-10-08 00:53:38 +00:00

medium

The error handling relies on checking the error message string (err.message?.includes("No server configured")). The API client layer in main-axios.ts provides structured errors with a code property (e.g., NO_SERVER_CONFIGURED). Using the error code is more robust and less prone to breaking if the error message changes.

      .catch((err) => {
        if (err.code !== "NO_SERVER_CONFIGURED") {
          toast.error(t("admin.failedToFetchPasswordLoginStatus"));
        }
      });
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) The error handling relies on checking the error message string (`err.message?.includes("No server configured")`). The API client layer in `main-axios.ts` provides structured errors with a `code` property (e.g., `NO_SERVER_CONFIGURED`). Using the error code is more robust and less prone to breaking if the error message changes. ```suggestion .catch((err) => { if (err.code !== "NO_SERVER_CONFIGURED") { toast.error(t("admin.failedToFetchPasswordLoginStatus")); } }); ```
@@ -1752,6 +1761,19 @@ export async function updateRegistrationAllowed(
}
gemini-code-assist[bot] (Migrated from github.com) commented 2025-10-08 00:53:38 +00:00

medium

The function updatePasswordLoginAllowed is typed to return Promise<any>. Based on the backend implementation, it returns an object { allowed: boolean }. Specifying the correct return type improves type safety and makes the code easier to understand and maintain.

export async function updatePasswordLoginAllowed(
  allowed: boolean,
): Promise<{ allowed: boolean }> {
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) The function `updatePasswordLoginAllowed` is typed to return `Promise<any>`. Based on the backend implementation, it returns an object `{ allowed: boolean }`. Specifying the correct return type improves type safety and makes the code easier to understand and maintain. ```suggestion export async function updatePasswordLoginAllowed( allowed: boolean, ): Promise<{ allowed: boolean }> { ```
Sign in to join this conversation.