Skip to content

Show Username/Password Login only if not disabled #3435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DanielRadlAMR
Copy link

@DanielRadlAMR DanielRadlAMR commented Aug 4, 2025

Fixes #3422

This PR improves the Login-UX by conditionally displaying the Username/Password Login only if it is not disabled in the System Settings.

Currently the login form is always shown, even when username/password login is disabled. The user only sees an error after attempting to log in.

  • A new API endpoint was added to fetch the disable_user_pass_login setting.

  • Login.vue uses this setting to determine whether to render the username/password login form.

Summary by CodeRabbit

  • New Features

    • The login page now dynamically hides the user-password login form and related UI elements when user-password login is disabled.
    • Users are informed if no login methods are available and advised to contact the administrator.
  • Bug Fixes

    • Improved handling for scenarios where all login methods are disabled, ensuring clear communication to users.

Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

A new backend API endpoint is added to expose whether user-password login is disabled. The frontend login page now conditionally displays the user-password login form and OAuth options based on this backend flag, and shows an informational message if no login methods are available.

Changes

Cohort / File(s) Change Summary
Frontend login conditional rendering
frontend/src/views/Login.vue
Introduced a resource to fetch the user-password login disabled flag from the backend and conditionally render the login form, OAuth separator, and fallback message based on this flag.
Backend API endpoint for login setting
hrms/api/system_settings.py
Added a new API endpoint get_user_pass_login_disabled to expose the disable_user_pass_login system setting, accessible to guests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend (Login.vue)
    participant Backend API (system_settings.py)
    participant System Settings

    User->>Frontend (Login.vue): Loads login page
    Frontend (Login.vue)->>Backend API (get_user_pass_login_disabled): GET disable_user_pass_login
    Backend API->>System Settings: Retrieve disable_user_pass_login
    System Settings-->>Backend API: Return flag value
    Backend API-->>Frontend (Login.vue): Return flag value
    alt User-password login enabled
        Frontend (Login.vue)-->>User: Show user-password login form and/or OAuth options
    else User-password login disabled and no OAuth
        Frontend (Login.vue)-->>User: Show "No login methods available" message
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix duplicated Salary Slip name after changing autoname format (#3434) No changes related to Salary Slip naming or Payroll module are present in this PR.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Addition of user-password login disable flag API and frontend logic (hrms/api/system_settings.py, frontend/src/views/Login.vue) These changes relate to login method availability and UI, not to Salary Slip naming or Payroll functionality.

Poem

A bunny hopped to the login screen,
And found new logic in between—
If passwords sleep, OAuth may play,
Or else a message saves the day.
Backend and frontend now align,
For login checks—how neat, how fine!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
hrms/api/system_settings.py (1)

4-5: Consider adding explicit boolean conversion for clarity.

While the current implementation works, consider ensuring the return value is explicitly boolean for better API consistency:

 def get_user_pass_login_disabled():
-    return frappe.get_system_settings("disable_user_pass_login")
+    return bool(frappe.get_system_settings("disable_user_pass_login"))
frontend/src/views/Login.vue (1)

170-170: Remove unnecessary method specification.

The method: 'GET' is redundant since GET is the default method for createResource.

 const user_pass_login_disabled = createResource({
 	url: "hrms.api.system_settings.get_user_pass_login_disabled",
-	method: 'GET',
 	initialData: [1],
 	auto: true,
 })
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be497bc and 64ccbc4.

📒 Files selected for processing (2)
  • frontend/src/views/Login.vue (4 hunks)
  • hrms/api/system_settings.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
hrms/api/system_settings.py (1)

1-6: Clean and focused API endpoint implementation.

The implementation is straightforward and serves its purpose well. The allow_guest=True decorator is appropriate since the login page needs to check this setting before authentication.

frontend/src/views/Login.vue (3)

13-13: Good conditional rendering implementation.

The conditional rendering of the login form based on the system setting is well implemented and improves user experience by preventing unnecessary form submission attempts.


39-39: Proper conditional rendering of separator text.

Good attention to detail in also conditionally rendering the "or" separator to maintain clean UI when the login form is hidden.


53-53: Excellent fallback message for better UX.

The informative message when no login methods are available provides clear guidance to users and significantly improves the user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Password Login not disableable
1 participant