-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add fields to input client id and secret for login providers, fix collapse state on login UI #491
Conversation
Reviewer's Guide by SourceryThis pull request implements a mechanism to persist the open/closed state of the login form across page refreshes. This is achieved by storing the state in localStorage using JavaScript and restoring it when the page loads. Sequence diagram for login form state persistencesequenceDiagram
participant User
participant Browser
participant LocalStorage
participant LoginForm
Note over Browser: Page Load
Browser->>LocalStorage: Get stored state
LocalStorage-->>Browser: Return state
Browser->>LoginForm: Apply stored state (open/closed)
Note over User: User interaction
User->>LoginForm: Click toggle button
LoginForm->>Browser: Toggle form visibility
Browser->>LocalStorage: Save new state
State diagram for login form collapse statesstateDiagram-v2
[*] --> Closed: Initial State
Closed --> Open: Toggle Button Click
Open --> Closed: Toggle Button Click
note right of Open
State persists after
page refresh
end note
note right of Closed
State persists after
page refresh
end note
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @HungNgien - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please remove the console.log statement before merging as it shouldn't be included in production code.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
} | ||
|
||
// Save state on toggle | ||
toggleLogin.addEventListener('click', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: The collapse state is being stored based on the current class rather than the final state after transition.
Consider using Bootstrap's 'shown.bs.collapse' and 'hidden.bs.collapse' events to ensure the correct state is stored after the transition completes.
const collapseStateKey = 'loginFormCollapseState'; | ||
|
||
// Restore state from localStorage | ||
const storedState = localStorage.getItem(collapseStateKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Add error handling for localStorage operations
localStorage might be unavailable in private browsing mode or if quota is exceeded. Consider wrapping these operations in try-catch blocks.
Suggested implementation:
// Restore state from localStorage
let storedState = null;
try {
storedState = localStorage.getItem(collapseStateKey);
console.log(storedState);
} catch (e) {
console.warn('Failed to read from localStorage:', e);
}
if (storedState === 'open') {
if (loginForm.classList.contains('in')) {
try {
localStorage.setItem(collapseStateKey, 'closed');
} catch (e) {
console.warn('Failed to write to localStorage:', e);
}
} else {
Updates:
Add client id and secret fields
Resolve the issue where the login form auto-collapses upon page refresh.
Summary by Sourcery
Bug Fixes: