Skip to content

Conversation

@slandath
Copy link
Member

@slandath slandath commented Aug 30, 2025

Closes #64

Summary by CodeRabbit

  • New Features

    • Introduced a dedicated Login page with email-based authentication and inline error messages.
    • Added Logout functionality with one-click access from the navigation bar.
    • Display of the logged-in username in the header.
  • Style

    • Updated navigation bar to show user controls only when authenticated and improved dropdown behavior.
  • Changes

    • Home page now requires login.
    • After login or logout, users are redirected to the home page.
    • Login URL standardized under the accounts section.

Signed-off-by: slandath <jesus_slanda@yahoo.com>
Signed-off-by: slandath <jesus_slanda@yahoo.com>
@slandath slandath requested a review from rakazirut August 30, 2025 02:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 30, 2025

Walkthrough

Introduces email-based authentication form, adds custom login/logout views and URLs, creates a login template, configures authentication redirects, makes the home page login-required, and conditionally renders navbar elements for authenticated users.

Changes

Cohort / File(s) Summary of Changes
Email authentication form
accounts/forms.py
Added EmailAuthenticationForm extending AuthenticationForm with email-based username and customized widgets; imported AuthenticationForm.
Auth views and routing
accounts/views.py, accounts/urls.py
Added CustomLoginView and CustomLogoutView; wired login/ and logout/ URL patterns; removed prior root path to home view.
Login template
accounts/templates/login.html
Added login page template rendering email/password fields, field and non-field errors, CSRF, submit button, and link to account creation.
Auth settings
fables/settings.py
Added LOGIN_REDIRECT_URL="/", LOGOUT_REDIRECT_URL="/", and LOGIN_URL="/accounts/login".
Authenticated UI and access
home/views.py, home/templates/base.html
Applied @login_required to home view; updated navbar to render only for authenticated users, show username, and provide CSRF-protected logout form; adjusted campaigns dropdown link behavior.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
home/templates/base.html (1)

18-56: Move the {% endif %} to after the collapse container’s closing </div>

--- home/templates/base.html
@@ around line 55
-          {% endif %}
         </ul>
-      </div>
+      </div>
+      {% endif %}
🧹 Nitpick comments (6)
accounts/forms.py (2)

41-46: Add UX/accessibility attrs to the email input.

Improve autofill and mobile keyboards.

Apply:

         widget=forms.EmailInput(
             attrs={
                 "id": "email",
                 "class": "form-control",
+                "autocomplete": "email",
+                "inputmode": "email",
+                "autocapitalize": "none",
+                "spellcheck": "false",
+                "autofocus": True,
             }
         ),

49-58: Enable password manager autofill.

Set autocomplete to current-password.

         widget=forms.PasswordInput(
             attrs={
                 "id": "password",
                 "class": "form-control",
+                "autocomplete": "current-password",
             }
         ),
accounts/urls.py (1)

8-9: Add app_name = "accounts" for URL namespacing
Logout is already implemented via POST in your templates, so no changes needed there.

accounts/views.py (1)

55-56: Remove next_page override and enforce POST-only logout

Delete the next_page attribute in CustomLogoutView so redirects use LOGOUT_REDIRECT_URL, and uncomment http_method_names = ["post"] to require a CSRF-protected POST. The logout link in home/templates/base.html:48 already uses a POST form.

accounts/templates/login.html (1)

26-37: Minor UX: add autocomplete and autofocus to inputs.

Improves browser autofill and mobile keyboard behavior.

-            {{ form.password }}
+            {{ form.password.as_widget(attrs={'autocomplete': 'current-password'}) }}

And for the email field above (if you adopt it):

-            {{ form.email }}
+            {{ form.email.as_widget(attrs={'autocomplete': 'username', 'autofocus': 'autofocus'}) }}
home/templates/base.html (1)

31-37: Optional: make “Campaigns” parent link keyboard-friendly.

Consider adding href="{% url 'campaigns' %}" plus data-bs-toggle="dropdown" so Enter navigates and Space opens dropdown, or add role="button" and aria-haspopup="true"/aria-expanded. Improves accessibility without changing behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3ac0a80 and b3df99c.

📒 Files selected for processing (7)
  • accounts/forms.py (2 hunks)
  • accounts/templates/login.html (1 hunks)
  • accounts/urls.py (1 hunks)
  • accounts/views.py (2 hunks)
  • fables/settings.py (1 hunks)
  • home/templates/base.html (2 hunks)
  • home/views.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
accounts/templates/login.html (1)
accounts/models.py (1)
  • Account (64-89)
accounts/urls.py (1)
accounts/views.py (2)
  • CustomLoginView (49-52)
  • CustomLogoutView (55-56)
fables/settings.py (1)
accounts/migrations/0001_initial.py (1)
  • Migration (7-72)
accounts/views.py (2)
accounts/forms.py (1)
  • EmailAuthenticationForm (38-58)
accounts/models.py (2)
  • Account (64-89)
  • AccountManager (23-45)
accounts/forms.py (1)
accounts/models.py (2)
  • Account (64-89)
  • AccountManager (23-45)
⏰ 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). (2)
  • GitHub Check: build-and-push
  • GitHub Check: build-and-push
🔇 Additional comments (11)
accounts/forms.py (2)

2-2: Correct import for overriding auth form.

Using AuthenticationForm is the right base for customizing login fields.


38-47: Email-as-username aligns with USERNAME_FIELD='email'.

Overriding the username field to EmailField with an EmailInput is appropriate here.

home/views.py (1)

1-6: login_required on home is correct and consistent with settings.

This matches LOGIN_URL (/accounts/login) and the redirect flow.

fables/settings.py (1)

95-97: Redirect settings verified and consistent – the LOGIN_URL, LOGIN_REDIRECT_URL, and LOGOUT_REDIRECT_URL entries in settings.py correspond to the login and logout routes defined in accounts/urls.py. Optionally, you can switch to using named URL reversals instead of hard-coded paths.

accounts/urls.py (1)

4-4: Direct imports for class-based views are fine.

Keeps references explicit.

accounts/views.py (3)

4-4: Auth views import is correct.


7-7: Form import includes the custom EmailAuthenticationForm.


49-52: LoginView configuration looks solid.

Template, form, and redirect_authenticated_user are all appropriate.

accounts/templates/login.html (2)

39-45: LGTM: non-field error rendering.

Shows authentication errors (e.g., “invalid credentials”) clearly.


13-24: Do not change to form.email—the form intentionally defines username as an EmailField
EmailAuthenticationForm subclasses AuthenticationForm and overrides its username field to be an email input. Replacing form.username with form.email would break rendering and error handling.

Likely an incorrect or invalid review comment.

home/templates/base.html (1)

48-53: Logout is correctly POST + CSRF.

Good adherence to best practices; no changes needed.

@slandath slandath merged commit 1f1a8c1 into main Aug 31, 2025
4 checks passed
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.

Login

3 participants