-
Notifications
You must be signed in to change notification settings - Fork 279
Fix security check notification not reappearing after dismissal #5933
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
base: develop
Are you sure you want to change the base?
Conversation
PasswordReminderService unmounts on logout and remounts after LOGIN dispatches, so componentDidUpdate never fires for the initial LOGIN transition. Add componentDidMount to persist the reducer-computed passwordReminder state (including the incremented nonPasswordLoginsCount) on mount so the count advances on disk across login cycles.
e968a00 to
cb243ec
Compare
swansontec
left a comment
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.
How about just replacing the PasswordReminderService with this:
import * as React from 'react'
import { setPasswordReminder } from '../../actions/LocalSettingsActions'
import { useAsyncEffect } from '../../hooks/useAsyncEffect'
import {
initialState,
type PasswordReminderState
} from '../../reducers/PasswordReminderReducer'
import { useDispatch, useSelector } from '../../types/reactRedux'
import { matchJson } from '../../util/matchJson'
interface Props {}
export const PasswordReminderService: React.FC<Props> = props => {
const settingsLoaded =
useSelector(state => state.ui.settings.settingsLoaded) ?? false
const passwordReminder = useSelector(state => state.ui.passwordReminder)
const lastPasswordReminder = React.useRef<PasswordReminderState>(initialState)
const dispatch = useDispatch()
useAsyncEffect(
async () => {
if (
settingsLoaded &&
!matchJson(passwordReminder, lastPasswordReminder.current)
) {
lastPasswordReminder.current = passwordReminder
await dispatch(setPasswordReminder(passwordReminder))
}
},
[settingsLoaded, passwordReminder],
'PasswordReminderService'
)
return null
}That way the useAsyncEffect runs not only on update, but also on first mount. At the same time, the code gets shorter & more modern.
| } | ||
|
|
||
| render() { | ||
| render(): React.JSX.Element | null { |
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.
This should be React.ReactElement for the return type, but for some reason revcode isn't flagging it. I guess edge-conventions has too many rules to hold the agent's attention.
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.
Fixed — changed return type to React.ReactElement | null.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Context
Asana: "Fix 'Security Check' notification trigger (reset PW)" (P0). After dismissing the Security Check modal once, it never reappears on subsequent logins — even though it should show within two non-password logins. This is the only way for users who forgot their password but can still PIN/bio login to reset it.
Regression introduced in 4.42.0 by commit
ef36815d47which consolidatedACCOUNT_INIT_COMPLETEinto theLOGINaction, changing the timing of settings initialization.Changes
PasswordReminderServiceis a class component that unmounts on logout and remounts afterLOGINdispatches. Because Redux state already contains the incrementednonPasswordLoginsCountby the time the component mounts,componentDidUpdatenever fires for the initial login transition — the "previous" and "current" props are identical from its perspective.This means the reducer-computed password reminder state (including the login counter) was never persisted to disk on login, so the count stayed stuck at a stale value across login cycles and the notification threshold was never reached.
Fix: Add
componentDidMounttoPasswordReminderServiceto persist the current reducer state to disk when the component mounts with loaded settings. This ensures thenonPasswordLoginsCountadvances on disk across login cycles without undoing the performance improvements from the originalLOGINconsolidation.Requirements
If you have made any visual changes to the GUI. Make sure you have:
Note
Low Risk
Small, localized lifecycle change that only affects when password-reminder settings are written to disk; low risk aside from potential extra write on mount.
Overview
Fixes a regression where the Security Check/password reminder state wasn’t being persisted on login, preventing the notification from re-triggering across subsequent non-password logins.
PasswordReminderServicenow persists the currentpasswordReminderto disk incomponentDidMountoncesettingsLoadedis true (in addition to the existingcomponentDidUpdatepersistence), ensuring the login counters/state advance even when the service remounts with already-updated redux state. Adds a CHANGELOG entry noting the fix.Written by Cursor Bugbot for commit ab3211f. This will update automatically on new commits. Configure here.