feat(mobile): login, password change and logout screens
P3 Task 3 移动端(对接 Task 2 api client + 本任务新增的后端契约): - 登录页实装:账号/密码表单(空值客户端校验)→ api.login(会话自动 持久化)→ pushReplacement /home;错误码本地化(AUTH_INVALID_ CREDENTIALS / AUTH_RATE_LIMITED(含稍后再试文案)/ 网络 / 校验); 提交加载态防重复提交。 - 修改密码页(设置页入口):当前/新/确认三字段,客户端校验(≥8 位、 两次一致)→ api.changePassword → toast + pop;成功后本地会话不变 (服务端保留当前会话);旧密码错误(401 AUTH_INVALID_CREDENTIALS) 显示「当前密码错误」且不触发 401 驱逐。 - 退出登录:设置页按钮 → api.logout 尽力而为 → 清会话 → 清栈回 /login;App 壳 initState 注册 onUnauthorized(业务 401 → 清栈 /login), 根 navigatorKey 接线;password-change 的 401 豁免会话驱逐(拦截器 豁免集合与令牌附加分离)。 - l10n:新增 16 组 zh/en 文案;错误码 → 文案解析扩展 (core/error_l10n.dart,errorCode→AppLocalizations)。 - 测试:ApiClient.changePassword 单测 ×2(Bearer+请求体;旧密码 401 不驱逐);widget 测试 ×12(登录 5:空值/成功跳转/凭据错误/限速文案/ 加载禁用;改密 4:过短/不一致/旧密码错误文案+会话保留/成功 toast+pop 且令牌不变;设置 2:改密入口跳转/登出清会话回登录;App 壳 1:401 清栈回 /login)。flutter analyze 0 issue;flutter test 81/81。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -20,5 +20,21 @@
|
||||
"homeTabAlbums": "Albums",
|
||||
"homeTabQueue": "Queue",
|
||||
"homeTabSettings": "Settings",
|
||||
"loginHint": "Sign in with your staff account"
|
||||
"loginHint": "Sign in with your staff account",
|
||||
"fieldRequired": "This field is required",
|
||||
"passwordChangeTitle": "Change password",
|
||||
"currentPassword": "Current password",
|
||||
"newPassword": "New password",
|
||||
"confirmNewPassword": "Confirm new password",
|
||||
"passwordMinLength": "New password must be at least 8 characters",
|
||||
"passwordMismatch": "New passwords do not match",
|
||||
"passwordChangeSuccess": "Password changed",
|
||||
"errorAuthInvalidCredentials": "Incorrect account or password",
|
||||
"errorOldPasswordIncorrect": "Current password is incorrect",
|
||||
"errorAuthRateLimited": "Too many attempts. Please try again later",
|
||||
"errorAuthTokenExpired": "Session expired. Please sign in again",
|
||||
"errorValidation": "Invalid input. Please check and retry",
|
||||
"errorNetwork": "Network error. Check your connection and retry",
|
||||
"errorNetworkTimeout": "Network timed out. Please retry",
|
||||
"errorInternal": "Service temporarily unavailable. Please retry later"
|
||||
}
|
||||
|
||||
@@ -223,6 +223,102 @@ abstract class AppLocalizations {
|
||||
/// In zh, this message translates to:
|
||||
/// **'使用工作人员账号登录'**
|
||||
String get loginHint;
|
||||
|
||||
/// No description provided for @fieldRequired.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'此项为必填项'**
|
||||
String get fieldRequired;
|
||||
|
||||
/// No description provided for @passwordChangeTitle.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'修改密码'**
|
||||
String get passwordChangeTitle;
|
||||
|
||||
/// No description provided for @currentPassword.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'当前密码'**
|
||||
String get currentPassword;
|
||||
|
||||
/// No description provided for @newPassword.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'新密码'**
|
||||
String get newPassword;
|
||||
|
||||
/// No description provided for @confirmNewPassword.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'确认新密码'**
|
||||
String get confirmNewPassword;
|
||||
|
||||
/// No description provided for @passwordMinLength.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'新密码至少需要 8 个字符'**
|
||||
String get passwordMinLength;
|
||||
|
||||
/// No description provided for @passwordMismatch.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'两次输入的新密码不一致'**
|
||||
String get passwordMismatch;
|
||||
|
||||
/// No description provided for @passwordChangeSuccess.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'密码已修改'**
|
||||
String get passwordChangeSuccess;
|
||||
|
||||
/// No description provided for @errorAuthInvalidCredentials.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'账号或密码错误'**
|
||||
String get errorAuthInvalidCredentials;
|
||||
|
||||
/// No description provided for @errorOldPasswordIncorrect.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'当前密码错误'**
|
||||
String get errorOldPasswordIncorrect;
|
||||
|
||||
/// No description provided for @errorAuthRateLimited.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'尝试次数过多,请稍后再试'**
|
||||
String get errorAuthRateLimited;
|
||||
|
||||
/// No description provided for @errorAuthTokenExpired.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'会话已过期,请重新登录'**
|
||||
String get errorAuthTokenExpired;
|
||||
|
||||
/// No description provided for @errorValidation.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'输入有误,请检查后重试'**
|
||||
String get errorValidation;
|
||||
|
||||
/// No description provided for @errorNetwork.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'网络连接失败,请检查网络后重试'**
|
||||
String get errorNetwork;
|
||||
|
||||
/// No description provided for @errorNetworkTimeout.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'网络超时,请重试'**
|
||||
String get errorNetworkTimeout;
|
||||
|
||||
/// No description provided for @errorInternal.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'服务暂时不可用,请稍后重试'**
|
||||
String get errorInternal;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate
|
||||
|
||||
@@ -70,4 +70,54 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
|
||||
@override
|
||||
String get loginHint => 'Sign in with your staff account';
|
||||
|
||||
@override
|
||||
String get fieldRequired => 'This field is required';
|
||||
|
||||
@override
|
||||
String get passwordChangeTitle => 'Change password';
|
||||
|
||||
@override
|
||||
String get currentPassword => 'Current password';
|
||||
|
||||
@override
|
||||
String get newPassword => 'New password';
|
||||
|
||||
@override
|
||||
String get confirmNewPassword => 'Confirm new password';
|
||||
|
||||
@override
|
||||
String get passwordMinLength => 'New password must be at least 8 characters';
|
||||
|
||||
@override
|
||||
String get passwordMismatch => 'New passwords do not match';
|
||||
|
||||
@override
|
||||
String get passwordChangeSuccess => 'Password changed';
|
||||
|
||||
@override
|
||||
String get errorAuthInvalidCredentials => 'Incorrect account or password';
|
||||
|
||||
@override
|
||||
String get errorOldPasswordIncorrect => 'Current password is incorrect';
|
||||
|
||||
@override
|
||||
String get errorAuthRateLimited =>
|
||||
'Too many attempts. Please try again later';
|
||||
|
||||
@override
|
||||
String get errorAuthTokenExpired => 'Session expired. Please sign in again';
|
||||
|
||||
@override
|
||||
String get errorValidation => 'Invalid input. Please check and retry';
|
||||
|
||||
@override
|
||||
String get errorNetwork => 'Network error. Check your connection and retry';
|
||||
|
||||
@override
|
||||
String get errorNetworkTimeout => 'Network timed out. Please retry';
|
||||
|
||||
@override
|
||||
String get errorInternal =>
|
||||
'Service temporarily unavailable. Please retry later';
|
||||
}
|
||||
|
||||
@@ -70,4 +70,52 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
|
||||
@override
|
||||
String get loginHint => '使用工作人员账号登录';
|
||||
|
||||
@override
|
||||
String get fieldRequired => '此项为必填项';
|
||||
|
||||
@override
|
||||
String get passwordChangeTitle => '修改密码';
|
||||
|
||||
@override
|
||||
String get currentPassword => '当前密码';
|
||||
|
||||
@override
|
||||
String get newPassword => '新密码';
|
||||
|
||||
@override
|
||||
String get confirmNewPassword => '确认新密码';
|
||||
|
||||
@override
|
||||
String get passwordMinLength => '新密码至少需要 8 个字符';
|
||||
|
||||
@override
|
||||
String get passwordMismatch => '两次输入的新密码不一致';
|
||||
|
||||
@override
|
||||
String get passwordChangeSuccess => '密码已修改';
|
||||
|
||||
@override
|
||||
String get errorAuthInvalidCredentials => '账号或密码错误';
|
||||
|
||||
@override
|
||||
String get errorOldPasswordIncorrect => '当前密码错误';
|
||||
|
||||
@override
|
||||
String get errorAuthRateLimited => '尝试次数过多,请稍后再试';
|
||||
|
||||
@override
|
||||
String get errorAuthTokenExpired => '会话已过期,请重新登录';
|
||||
|
||||
@override
|
||||
String get errorValidation => '输入有误,请检查后重试';
|
||||
|
||||
@override
|
||||
String get errorNetwork => '网络连接失败,请检查网络后重试';
|
||||
|
||||
@override
|
||||
String get errorNetworkTimeout => '网络超时,请重试';
|
||||
|
||||
@override
|
||||
String get errorInternal => '服务暂时不可用,请稍后重试';
|
||||
}
|
||||
|
||||
@@ -20,5 +20,21 @@
|
||||
"homeTabAlbums": "相册",
|
||||
"homeTabQueue": "队列",
|
||||
"homeTabSettings": "设置",
|
||||
"loginHint": "使用工作人员账号登录"
|
||||
"loginHint": "使用工作人员账号登录",
|
||||
"fieldRequired": "此项为必填项",
|
||||
"passwordChangeTitle": "修改密码",
|
||||
"currentPassword": "当前密码",
|
||||
"newPassword": "新密码",
|
||||
"confirmNewPassword": "确认新密码",
|
||||
"passwordMinLength": "新密码至少需要 8 个字符",
|
||||
"passwordMismatch": "两次输入的新密码不一致",
|
||||
"passwordChangeSuccess": "密码已修改",
|
||||
"errorAuthInvalidCredentials": "账号或密码错误",
|
||||
"errorOldPasswordIncorrect": "当前密码错误",
|
||||
"errorAuthRateLimited": "尝试次数过多,请稍后再试",
|
||||
"errorAuthTokenExpired": "会话已过期,请重新登录",
|
||||
"errorValidation": "输入有误,请检查后重试",
|
||||
"errorNetwork": "网络连接失败,请检查网络后重试",
|
||||
"errorNetworkTimeout": "网络超时,请重试",
|
||||
"errorInternal": "服务暂时不可用,请稍后重试"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user