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 _isLoading = true;
|
||||||
|
|
||||||
|
/// 加载状态是否出错
|
||||||
|
bool _isLoadError = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
@ -58,6 +61,7 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
|
||||||
Future<void> _loadPasswordStatus() async {
|
Future<void> _loadPasswordStatus() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
_isLoadError = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -73,8 +77,7 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// 出错时默认已设置密码(注册时必须设置)
|
_isLoadError = true;
|
||||||
_hasPassword = true;
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -221,6 +224,23 @@ class _ChangePasswordPageState extends ConsumerState<ChangePasswordPage> {
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
|
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(
|
: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue