feat: Cookie auth improvements and cached auth state#356
Conversation
Summary of ChangesHello, 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 significantly upgrades Docula's cookie-based authentication system by moving from a simple cookie name check to a more robust URL-based authentication verification. The primary goal is to enhance user experience by preventing UI flashes during page loads through client-side caching of authentication states. This change also improves the flexibility of integrating with various authentication providers and streamlines the display of user information and API authorization status across the documentation site. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the cookie-based authentication system to use a configurable authCheckUrl for determining login status, replacing the previous JWT cookie name check. The changes include updating documentation, configuration types, and various Handlebars templates to support the new fetch-based authentication, introduce cached auth state in localStorage to prevent UI flickering, and allow for extracting a user display name from the authCheckUrl response. Review comments suggest improving code readability and maintainability by combining and formatting inline JavaScript scripts in api.hbs, header-bar.hbs, and header.hbs, and addressing the use of !important in styles.css by refactoring JavaScript to toggle classes instead of inline styles.
| .cookie-auth-user:empty { | ||
| display: none; | ||
| display: none !important; | ||
| } |
There was a problem hiding this comment.
The use of !important is generally discouraged as it can lead to maintenance issues and difficulty in overriding styles. This rule is likely necessary because the accompanying JavaScript is setting inline style attributes, which have higher specificity than class-based styles. By refactoring the JavaScript to only toggle classes on a parent element (as suggested in another comment for templates/modern/includes/scripts.hbs), this !important rule can be removed.
| .cookie-auth-user:empty { | |
| display: none; | |
| display: none !important; | |
| } | |
| .cookie-auth-user:empty { | |
| display: none; | |
| } |
There was a problem hiding this comment.
From Claude:
The !important is intentional here. .docula-auth-logged-in .cookie-auth-user (line 127) sets display: inline with specificity 0,2,0. .cookie-auth-user:empty also has specificity 0,2,0, but it appears after the logged-in rule, so it only wins by source order. That's fragile — any future reordering of the CSS would break it. The !important makes the intent explicit: an empty username element should never be visible regardless of auth state.
There are no inline styles being set on this element — the JS sets textContent, not style. So the premise of the suggestion (that !important is fighting inline styles) doesn't apply here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #356 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 1818 1818
Branches 514 520 +6
=========================================
Hits 1818 1818 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR:
New config options
Test plan