Skip to content

Commit a94cbb1

Browse files
committed
feat: 增加用户取消验证码输入的处理逻辑
1 parent 8877ae2 commit a94cbb1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/(guest)/sso-login.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,17 @@ const UnifiedLoginPage: React.FC = () => {
106106

107107
try {
108108
const cookies = await ssoLogin.current!.login(account, accountPassword, twoFactorCallback);
109+
// 如果返回空字符串,说明用户取消了验证码输入
110+
if (!cookies) {
111+
console.log('用户取消了SSO登录');
112+
return false;
113+
}
109114
await AsyncStorage.setItem(SSO_LOGIN_COOKIE_KEY, cookies);
110115
await AsyncStorage.setItem(SSO_LOGIN_USER_KEY, JSON.stringify({ account: account, password: accountPassword }));
111116
console.log('登录SSO成功:', cookies);
112117
return true;
113118
} catch (error: any) {
114-
// 这个 code 和 msg 是 SSO 提供的不是我们自己定义的
119+
// 这个 code 和 msg 是 SSO 提供的,不是我们自己定义的
115120
const data = handleError(error) as { code: string; msg: string };
116121
if (data) {
117122
Alert.alert('请求失败', data.code + ': ' + data.msg);

lib/sso-login.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,8 @@ class SSOLogin {
207207
// 调用回调获取用户输入的验证码
208208
const userInputCode = await twoFactorCallback.onSmsRequired(phone, tip, sendSms);
209209
if (!userInputCode) {
210-
throw {
211-
type: RejectEnum.NativeLoginFailed,
212-
data: '用户取消了验证码输入',
213-
};
210+
console.log('用户取消了验证码输入');
211+
return ''; // 返回空字符串表示用户取消
214212
}
215213

216214
// 验证验证码

0 commit comments

Comments
 (0)