Skip to content

Commit e2fc8e8

Browse files
committed
fix: surface cancelLogin failures instead of swallowing them in console
Both cancel paths (resetToPasswordFlow and handleDelete) reset the UI optimistically and fired cancelLogin() without handling failure beyond a console.error - on a network failure the server-side pending challenge silently survived until its 300s TTL while the UI told the user it was cancelled. Extract the duplicated call into a single cancelPendingLogin() helper that warns the user via the existing snackbar when the server-side invalidation fails, so they know the pending verification will only die by its own TTL. The optimistic reset is kept - the user asked to cancel, so returning control immediately stays correct. PR #142 review finding LOW #2.
1 parent 246c777 commit e2fc8e8

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

resources/js/login/login.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ class LoginPage extends React.Component {
126126
this.onUseRecovery = this.onUseRecovery.bind(this);
127127
this.onBackToOtp = this.onBackToOtp.bind(this);
128128
this.resetToPasswordFlow = this.resetToPasswordFlow.bind(this);
129+
this.cancelPendingLogin = this.cancelPendingLogin.bind(this);
130+
}
131+
132+
/**
133+
* Best-effort server-side invalidation of the pending MFA challenge.
134+
* The UI resets optimistically; if the request fails the user is told the
135+
* pending verification will only die by its own TTL.
136+
*/
137+
cancelPendingLogin() {
138+
cancelLogin(this.props.token).catch((error) => {
139+
console.error("cancelLogin failed", error);
140+
this.showAlert(
141+
"We couldn't cancel the pending verification on the server. It will expire on its own in a few minutes.",
142+
"warning",
143+
);
144+
});
129145
}
130146

131147
showAlert(message, severity) {
@@ -315,9 +331,7 @@ class LoginPage extends React.Component {
315331
password: "",
316332
},
317333
});
318-
cancelLogin(this.props.token).catch((error) => {
319-
console.error("cancelLogin failed", error);
320-
});
334+
this.cancelPendingLogin();
321335
}
322336

323337
/**
@@ -643,9 +657,7 @@ class LoginPage extends React.Component {
643657
// A pending 2FA/recovery challenge was issued server-side (session
644658
// 2fa_pending_user_id + an unredeemed OTP); invalidate it the same
645659
// way "Cancel" does instead of leaving it live until its TTL.
646-
cancelLogin(this.props.token).catch((error) => {
647-
console.error("cancelLogin failed", error);
648-
});
660+
this.cancelPendingLogin();
649661
}
650662
this.setState({
651663
...this.state,

0 commit comments

Comments
 (0)