fix(auth): a member behind the register's clock says the password changed
When a member's clock ran more than its allowance behind the register's, the session after a reset was refused as unavailable (the re-review's tenth finding), after the register had already reset the account and ended every session, and the app read it as "this instance has no password sign-in". It now has a refusal of its own (passwordChanged): the app says the password was changed and to sign in again with the new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
293ec6b103
commit
09a627d1c7
3 changed files with 60 additions and 7 deletions
|
|
@ -86,7 +86,13 @@ enum PasswordRefusal implements _is.SerializableModel {
|
|||
|
||||
/// Ten codes in a row from this signed-in session were wrong: the
|
||||
/// session ended (the re-review's third finding); sign in again.
|
||||
sessionEnded;
|
||||
sessionEnded,
|
||||
|
||||
/// The password was changed (a reset carried out), but this service
|
||||
/// couldn't open a session for it yet (its clock is behind the
|
||||
/// register's): sign in again with the new password. Never "this
|
||||
/// instance has no password sign-in" (the re-review's tenth finding).
|
||||
passwordChanged;
|
||||
|
||||
static PasswordRefusal fromJson(String name) {
|
||||
switch (name) {
|
||||
|
|
@ -130,6 +136,8 @@ enum PasswordRefusal implements _is.SerializableModel {
|
|||
return PasswordRefusal.codesWait;
|
||||
case 'sessionEnded':
|
||||
return PasswordRefusal.sessionEnded;
|
||||
case 'passwordChanged':
|
||||
return PasswordRefusal.passwordChanged;
|
||||
default:
|
||||
throw ArgumentError(
|
||||
'Value "$name" cannot be converted to "PasswordRefusal"',
|
||||
|
|
|
|||
|
|
@ -56,3 +56,8 @@ values:
|
|||
### Ten codes in a row from this signed-in session were wrong: the
|
||||
### session ended (the re-review's third finding); sign in again.
|
||||
- sessionEnded
|
||||
### The password was changed (a reset carried out), but this service
|
||||
### couldn't open a session for it yet (its clock is behind the
|
||||
### register's): sign in again with the new password. Never "this
|
||||
### instance has no password sign-in" (the re-review's tenth finding).
|
||||
- passwordChanged
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ Future<AuthSuccess> issueSession(
|
|||
/// password or of the account): those here end first, as the register's
|
||||
/// notice to this server will end them, and the new one is made only once
|
||||
/// this server's clock is past that moment, so the notice, whenever it
|
||||
/// arrives, leaves it.
|
||||
/// arrives, leaves it. A clock more than [maxClockSkew] behind is refused
|
||||
/// ([PasswordRefusal.passwordChanged]): the reset is done, and the device
|
||||
/// signs in again with the new password.
|
||||
Future<AuthSuccess> issueSessionAfter(
|
||||
Session session,
|
||||
UuidValue account, {
|
||||
|
|
@ -89,7 +91,8 @@ Future<AuthSuccess> issueSessionAfter(
|
|||
'set both by NTP.',
|
||||
level: LogLevel.warning,
|
||||
);
|
||||
throw PasswordRefusedException(reason: PasswordRefusal.unavailable);
|
||||
// The reset is done: the device signs in again, with the new password.
|
||||
throw PasswordRefusedException(reason: PasswordRefusal.passwordChanged);
|
||||
}
|
||||
if (!wait.isNegative) {
|
||||
await Future<void>.delayed(wait + const Duration(milliseconds: 1));
|
||||
|
|
|
|||
Loading…
Reference in a new issue