fix(security): 修复修改登录密码页面加载失败时静默降级的 bug
与 change_payment_password_page 同款问题:加载失败时原本默默设为 hasPassword=true(注册时必须设置的假设),改为显示错误状态+重试按钮。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9c84be72bc
commit
34603aac8e
|
|
@ -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,6 +224,23 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
|
|||
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
|
||||
),
|
||||
)
|
||||
: _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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue