Skip to content

Commit

Permalink
fix: Update auth flow by new restore policy (#2253)
Browse files Browse the repository at this point in the history
* fix: Update auth flow by new restore policy

* chore: remove duplications

* fix: sss stack updates

* fix: Backup flow updates

* fix: Restore backup
  • Loading branch information
devkudasov authored Jan 7, 2025
1 parent b64adac commit 95c97f3
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 209 deletions.
2 changes: 0 additions & 2 deletions assets/locales/ar/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,6 @@
"signupNetworkExitsAlertTitle": "هل أنت متأكد من أنك تريد استبدال حسابك؟",
"signupNetworkExitsDescription1": "يمكنك استعادة حسابك أو استبداله.",
"signupNetworkExitsDescription2": "في حالة الاستبدال، ستفقد جميع بيانات الحساب",
"signupNetworkExitsTitle": "لديك حساب بالفعل على {{provider}} تسجيل الدخول {{email}}",
"signupNetworkExitsTitleWithoutEmail": "لديك حساب بالفعل على {{provider}}",
"signupStoreWalletAccountNumber": "حساب #{{number}}",
"signupStoreWalletCreatingAccount": "جارٍ إنشاء حسابك",
"sliderCaptchaDragText": "اسحب الشريط",
Expand Down
2 changes: 0 additions & 2 deletions assets/locales/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,6 @@
"signupNetworkExitsAlertTitle": "Are you sure you want to replace this account?",
"signupNetworkExitsDescription1": "You can choose to restore or replace your account.",
"signupNetworkExitsDescription2": "If you replace this account, all data will be lost.",
"signupNetworkExitsTitle": "You already have an account on {{provider}} login {{email}}",
"signupNetworkExitsTitleWithoutEmail": "You already have an account on {{provider}} login",
"signupStoreWalletAccountNumber": "Account #{{number}}",
"signupStoreWalletCreatingAccount": "Creating your account",
"sliderCaptchaDragText": "Drag the slider",
Expand Down
2 changes: 0 additions & 2 deletions assets/locales/id/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,6 @@
"signupNetworkExitsAlertTitle": "Apakah Anda yakin ingin mengganti akun Anda?",
"signupNetworkExitsDescription1": "Anda dapat memulihkan akun Anda atau menggantinya.",
"signupNetworkExitsDescription2": "Dalam kasus penggantian, semua data akun akan hilang",
"signupNetworkExitsTitle": "Anda sudah memiliki akun di login {{provider}} {{email}}",
"signupNetworkExitsTitleWithoutEmail": "Anda sudah memiliki akun di login {{provider}}",
"signupStoreWalletAccountNumber": "Akun #{{number}}",
"signupStoreWalletCreatingAccount": "Membuat akun Anda",
"sliderCaptchaDragText": "Geser penggeser",
Expand Down
2 changes: 0 additions & 2 deletions assets/locales/tr/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,6 @@
"signupNetworkExitsAlertTitle": "Hesabınızı değiştirmek istediğinizden emin misiniz?",
"signupNetworkExitsDescription1": "Hesabınızı geri yükleyebilir veya değiştirebilirsiniz.",
"signupNetworkExitsDescription2": "Değiştirilmesi durumunda tüm hesap verileri kaybolacaktır",
"signupNetworkExitsTitle": "{{provider}} giriş {{email}} ile zaten bir hesabınız var",
"signupNetworkExitsTitleWithoutEmail": "{{provider}} giriş ile zaten bir hesabınız var",
"signupStoreWalletAccountNumber": "Hesap #{{number}}",
"signupStoreWalletCreatingAccount": "Hesabınız oluşturuluyor",
"sliderCaptchaDragText": "Sürgüyü sürükle",
Expand Down
4 changes: 0 additions & 4 deletions src/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,6 @@ export const ar = {
'لا توجد حسابات مرتبطة في شبكتنا لتسجيل الدخول الاجتماعي الذي اخترته. قم بإنشاء حساب جديد بناءً على تسجيل الدخول الاجتماعي هذا أو اختر تسجيل دخول اجتماعي آخر',
[I18N.signNotExitsTitle]:
'لم نجد الحساب متصلاً بتسجيل الدخول {{provider}} {{email}}',
[I18N.signupNetworkExitsTitle]:
'لديك بالفعل حساب على {{provider}} تسجيل الدخول {{email}}',
[I18N.signupNetworkExitsTitleWithoutEmail]:
'لديك بالفعل حساب على {{provider}} تسجيل الدخول',
[I18N.signupNetworkExitsDescription1]: 'يمكنك استعادة حسابك أو استبداله.',
[I18N.signupNetworkExitsDescription2]:
'في حالة الاستبدال, سيتم فقدان جميع بيانات الحساب',
Expand Down
71 changes: 30 additions & 41 deletions src/components/signin-networks/signin-networks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,43 +41,32 @@ export const SigninNetworks = observer(
isCustomSupported,
onPressHardwareWallet,
}: SssNetworksProps) => {
const [isApple, setIsApple] = useState(false);
const [isGoogle, setIsGoogle] = useState(false);
const [isCustom, setIsCustom] = useState(false);
const isLoading = useMemo(
() => isApple || isGoogle || isCustom,
[isApple, isGoogle, isCustom],
);

const onPressLoginCustom = useCallback(async () => {
try {
setIsCustom(true);

await onLogin(SssProviders.custom);
} finally {
setIsCustom(false);
}
}, [onLogin]);

const onPressLoginGoogle = useCallback(async () => {
try {
setIsGoogle(true);

await onLogin(SssProviders.google);
} finally {
setIsGoogle(false);
}
}, [onLogin]);
const [isLoading, setIsLoading] = useState<SssProviders | null>(null);

const onPressLoginApple = useCallback(async () => {
try {
setIsApple(true);
const isApple = useMemo(
() => isLoading === SssProviders.apple,
[isLoading],
);
const isGoogle = useMemo(
() => isLoading === SssProviders.google,
[isLoading],
);
const isCustom = useMemo(
() => isLoading === SssProviders.custom,
[isLoading],
);

await onLogin(SssProviders.apple);
} finally {
setIsApple(false);
}
}, [onLogin]);
const onPressLogin = useCallback(
(sssProvider: SssProviders) => async () => {
try {
setIsLoading(sssProvider);
await onLogin(sssProvider);
} finally {
setIsLoading(null);
}
},
[onLogin],
);

const mnemonicWalletsCount = Wallet.getAll().filter(
wallet => wallet.type === WalletType.mnemonic,
Expand Down Expand Up @@ -105,8 +94,8 @@ export const SigninNetworks = observer(
<Spacer height={10} />
<SocialButton
loading={isApple}
disabled={isLoading && !isApple}
onPress={onPressLoginApple}
disabled={Boolean(isLoading && !isApple)}
onPress={onPressLogin(SssProviders.apple)}
variant={SocialButtonVariant.apple}
testID="sss_login_apple"
/>
Expand All @@ -117,8 +106,8 @@ export const SigninNetworks = observer(
<Spacer height={10} />
<SocialButton
loading={isGoogle}
disabled={isLoading && !isGoogle}
onPress={onPressLoginGoogle}
disabled={Boolean(isLoading && !isGoogle)}
onPress={onPressLogin(SssProviders.google)}
variant={SocialButtonVariant.google}
testID="sss_login_google"
/>
Expand All @@ -129,8 +118,8 @@ export const SigninNetworks = observer(
<Spacer height={10} />
<Button
loading={isCustom}
disabled={isLoading && !isCustom}
onPress={onPressLoginCustom}
disabled={Boolean(isLoading && !isCustom)}
onPress={onPressLogin(SssProviders.custom)}
i18n={I18N.customNetwork}
variant={ButtonVariant.contained}
testID="sss_login_custom"
Expand Down
2 changes: 0 additions & 2 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ export enum I18N {
sssMigrateRewriteDescription = 'sssMigrateRewriteDescription',
sssMigrateRewriteAlertTitle = 'sssMigrateRewriteAlertTitle',
sssMigrateRewriteAlertDescription = 'sssMigrateRewriteAlertDescription',
signupNetworkExitsTitle = 'signupNetworkExitsTitle',
signupNetworkExitsTitleWithoutEmail = 'signupNetworkExitsTitleWithoutEmail',
signupNetworkExitsDescription1 = 'signupNetworkExitsDescription1',
signupNetworkExitsDescription2 = 'signupNetworkExitsDescription2',
signupNetworkExitsAlertTitle = 'signupNetworkExitsAlertTitle',
Expand Down
10 changes: 5 additions & 5 deletions src/route-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export enum SignUpStackRoutes {
SignUpAgreement = 'signupAgreement',
SignUpNetworks = 'signupNetworks',
SignUpPin = 'signupPin',
OnboardingSetupPin = 'onboardingSetupPin',
OnboardingSetupPin = 'signupOnboardingSetupPin',
SignupStoreWallet = 'signupStoreWallet',
SignupCloudProblems = 'cloudProblems',
SignupCloudProblems = 'signupCloudProblems',
SignupImportantInfo = 'signupImportantInfo',
}

Expand Down Expand Up @@ -742,12 +742,12 @@ export enum SignInStackRoutes {
SigninAgreement = 'signinAgreement',
SigninRestoreWallet = 'signinRestoreWallet',
SigninPin = 'signinPin',
OnboardingSetupPin = 'onboardingSetupPin',
OnboardingSetupPin = 'signinOnboardingSetupPin',
SigninStoreWallet = 'signinStoreWallet',
SigninNotExists = 'signinNotExists',
SigninNotRecovery = 'signinNotRecovery',
SigninCloudProblems = 'cloudProblems',
SigninChooseAccount = 'chooseAccount',
SigninCloudProblems = 'signinCloudProblems',
SigninChooseAccount = 'signinChooseAccount',
SigninSharesNotFound = 'signinSharesNotFound',
}

Expand Down
8 changes: 3 additions & 5 deletions src/screens/HomeStack/SssMigrate/sss-migrate-networks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ export const SssMigrateNetworksScreen = memo(() => {
//@ts-ignore
navigation.navigate(nextScreen, {
accountId: route.params.accountId,
privateKey: new SecureValue<string | null | undefined>(
creds?.privateKey,
),
token: creds?.token,
verifier: creds?.verifier,
privateKey: new SecureValue<string | null>(creds!.privateKey),
token: creds!.token,
verifier: creds!.verifier,
provider,
email: '',
});
Expand Down
Loading

0 comments on commit 95c97f3

Please sign in to comment.