fix(security): 修复修改登录密码页面加载失败时静默降级的 bug

与 change_payment_password_page 同款问题:加载失败时原本默默设为
hasPassword=true(注册时必须设置的假设),改为显示错误状态+重试按钮。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-05 09:17:53 -08:00
parent 9c84be72bc
commit 34603aac8e
1 changed files with 23 additions and 3 deletions

View File

@ -40,6 +40,9 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
///
bool _isLoading = true;
///
bool _isLoadError = false;
@override
void initState() {
super.initState();
@ -58,6 +61,7 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
Future<void> _loadPasswordStatus() async {
setState(() {
_isLoading = true;
_isLoadError = false;
});
try {
@ -73,8 +77,7 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
} catch (e) {
if (mounted) {
setState(() {
//
_hasPassword = true;
_isLoadError = true;
_isLoading = false;
});
}
@ -221,7 +224,24 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
),
)
: SingleChildScrollView(
: _isLoadError
? Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.error_outline, color: Colors.red, size: 48),
const SizedBox(height: 12),
const Text('加载失败,请重试', style: TextStyle(color: Colors.red)),
const SizedBox(height: 16),
ElevatedButton(
onPressed: _loadPasswordStatus,
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFD4AF37)),
child: const Text('重试', style: TextStyle(color: Colors.white)),
),
],
),
)
: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,