Skip to content

Commit

Permalink
fix login loading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LastStranger committed Mar 7, 2024
1 parent c65e282 commit c03552a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ const Index = () => {
try {
const res = await request.get("/auth/user", {
headers: { Authorization: `Basic ${encodedAuth}` },
withCredentials: true,
withCredentials: ifNeedCookie,
});
// console.log(res);
if (res.data.requiresTwoFactorAuth) {
setIfNeedCode(true);
setIsSubmitting(false);
return;
}

Expand Down Expand Up @@ -138,15 +139,15 @@ const Index = () => {
{ifNeedCode && (
<View>
<View className="mt-2 flex-row items-center">
<Text className="color color-[#6ae3f9] text-base">验证码:</Text>
<Text className="color color-[#6ae3f9] text-base">邮箱验证码:</Text>
<TextInput
className="color-[#6ae3f9] ml-2 flex-1 rounded border-2 border-[#053c48] bg-[#05191d] px-3 py-3 text-lg/6"
placeholder="请输入验证码"
placeholder="请输入邮箱验证码"
placeholderTextColor="#757575"
onChangeText={val => handleFormChange({ authCode: val })}
/>
</View>
<Text onPress={() => handleLogin(false)}>没收到?尝试清除cookie再试一次</Text>
<Text onPress={() => handleLogin(false)}>没收到验证码?点击此处重发验证码</Text>
</View>
)}
<TouchableOpacity
Expand Down
4 changes: 4 additions & 0 deletions src/store/useUserStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const useUserStore = create<UserInfoState>(set => ({
// headers: { Authorization: `Basic ${encodedAuth}` },
// withCredentials: false,
});
if (!res.data?.id) {
set({ loading: false });
return;
}
set({ userInfo: res.data, loading: false });
} catch (e) {
set({ loading: false });
Expand Down

0 comments on commit c03552a

Please sign in to comment.