From 27e30ce3fb74ea45921b9a8541eead7bc8f97976 Mon Sep 17 00:00:00 2001 From: Ramon Candel Date: Thu, 16 Oct 2025 08:35:30 +0200 Subject: [PATCH 1/2] Remove SignUp functionality and related components --- src/components/forms/SignUpForm/index.tsx | 336 ------------------ src/navigation/LinkingConfiguration.ts | 1 - src/navigation/RootNavigator.tsx | 8 - .../DeactivatedAccountScreen.tsx | 11 +- src/screens/SignUpScreen/index.tsx | 92 ----- src/services/AuthService.ts | 87 +---- src/types/navigation.ts | 1 - src/types/ui.ts | 5 - 8 files changed, 10 insertions(+), 531 deletions(-) delete mode 100644 src/components/forms/SignUpForm/index.tsx delete mode 100644 src/screens/SignUpScreen/index.tsx diff --git a/src/components/forms/SignUpForm/index.tsx b/src/components/forms/SignUpForm/index.tsx deleted file mode 100644 index 37faaf76f..000000000 --- a/src/components/forms/SignUpForm/index.tsx +++ /dev/null @@ -1,336 +0,0 @@ -import { Controller, useForm } from 'react-hook-form'; -import React, { useEffect, useRef, useState } from 'react'; -import { useTailwind } from 'tailwind-rn'; -import { yupResolver } from '@hookform/resolvers/yup'; -import * as yup from 'yup'; -import strings from '../../../../assets/lang/strings'; -import { BaseFormProps, SignUpFormData } from '../../../types/ui'; -import AppTextInput from '../../AppTextInput'; -import { useAppDispatch } from '../../../store/hooks'; -import { authThunks } from '../../../store/slices/auth'; -import analytics, { AnalyticsEventKey } from '../../../services/AnalyticsService'; -import errorService from '../../../services/ErrorService'; -import { Linking, TextInput, TouchableWithoutFeedback, useWindowDimensions, View } from 'react-native'; -import authService from '../../../services/AuthService'; -import { DevicePlatform } from '../../../types'; -import { Eye, EyeSlash, Info, WarningCircle } from 'phosphor-react-native'; -import useGetColor from '../../../hooks/useColor'; -import validationService from '../../../services/ValidationService'; -import AppText from '../../AppText'; -import { auth } from '@internxt/lib'; - -import appService from '@internxt-mobile/services/AppService'; -import StrengthMeter from 'src/components/StrengthMeter'; -import { INCREASED_TOUCH_AREA } from 'src/styles/global'; - -const schema: yup.SchemaOf = yup - .object() - .shape({ - email: yup - .string() - .required(strings.errors.requiredField) - .test({ - name: 'validEmail', - message: strings.errors.validEmail, - test: function (value) { - return validationService.validateEmail(value || ''); - }, - }), - password: yup.string().required(strings.errors.requiredField), - }) - .required(); - -const CreateAccountError = { - EmailAlreadyInUse: strings.errors.emailAlreadyInUse, -}; -type PasswordStrengthLevel = 'NOT_LONG_ENOUGH' | 'NOT_COMPLEX_ENOUGH' | 'MEDIUM' | 'HARD' | undefined; -const SignUpForm = (props: BaseFormProps) => { - const tailwind = useTailwind(); - const getColor = useGetColor(); - const dispatch = useAppDispatch(); - const passwordInputRef = useRef(null); - const { width: windowWidth } = useWindowDimensions(); - const [isLoading, setIsLoading] = useState(false); - const [showPassword, setShowPassword] = useState(false); - const [isSubmitted, setIsSubmitted] = useState(false); - const [createAccountError, setCreateAccountError] = useState(undefined); - const [passwordStrengthLevel, setPasswordStrengthLevel] = useState(); - const [twoFactorCode] = useState(''); - const [recaptchaToken] = useState(''); - const { - control, - handleSubmit, - formState: { isValid, isDirty, errors }, - getValues, - watch, - } = useForm({ - mode: 'all', - resolver: yupResolver(schema), - defaultValues: { - email: '', - password: '', - }, - }); - - useEffect(() => { - if (isSubmitted) { - setIsSubmitted(false); - } - validatePasswordStrength(); - }, [watch().email, watch().password]); - - const validatePasswordStrength = () => { - const { email, password } = getValues(); - - const result = auth.testPasswordStrength(password, email); - if ('reason' in result) { - setPasswordStrengthLevel(result.reason); - } - - if ('strength' in result) { - setPasswordStrengthLevel(result.strength.toUpperCase() as PasswordStrengthLevel); - } - }; - const getEmailError = (): ['error' | 'success' | 'warning' | 'idle', JSX.Element] => { - if ((errors?.email?.message || createAccountError) && isSubmitted) { - return [ - 'error' as 'error' | 'success' | 'warning' | 'idle', - - - {errors?.email?.message || createAccountError} - , - ]; - } - - return ['idle', <>]; - }; - - const getPasswordStrengthMessage = () => { - if (passwordStrengthLevel === 'MEDIUM') { - return strings.messages.passwordMediumStrength; - } - if (passwordStrengthLevel === 'HARD') { - return strings.messages.passwordHardStrength; - } - - if (passwordStrengthLevel === 'NOT_LONG_ENOUGH') { - return strings.errors.passwordLength; - } - if (passwordStrengthLevel === 'NOT_COMPLEX_ENOUGH') { - return strings.errors.passwordComplex; - } - return ''; - }; - const renderPasswordStrengthMeter = () => { - const emailError = control.getFieldState('email').error; - if (!emailError && isSubmitted && !getValues().password) { - return ( - - - {strings.errors.requiredField} - - ); - } - if (!getValues().password) return; - let strength = 1; - - if (passwordStrengthLevel === 'MEDIUM') { - strength = 2; - } - if (passwordStrengthLevel === 'HARD') { - strength = 3; - } - - return ( - - - - ); - }; - - const getPasswordStatus = () => { - const emailError = control.getFieldState('email').error; - const passwordError = control.getFieldState('password').error; - if (!emailError && passwordError && isSubmitted) { - return 'error'; - } - if (passwordStrengthLevel === 'HARD') return 'success'; - if (passwordStrengthLevel === 'MEDIUM') return 'warning'; - if (getValues().password) return 'error'; - return 'idle'; - }; - const toggleShowNewPassword = () => setShowPassword(!showPassword); - - const onSubmitButtonPressed = () => { - setIsSubmitted(true); - if (getValues().password && passwordStrengthLevel !== 'HARD' && passwordStrengthLevel !== 'MEDIUM') return; - handleSubmit(async (data) => { - setCreateAccountError(undefined); - setIsLoading(true); - - try { - const userData = await authService.doRegister({ - firstName: authService.defaultName, - lastName: authService.defaultLastname, - email: data.email, - password: data.password, - captcha: recaptchaToken, - }); - - await Promise.all([ - analytics.identify(userData.uuid, { email: data.email }), - analytics.track(AnalyticsEventKey.UserSignUp, { - properties: { - userId: userData.uuid, - email: data.email, - platform: DevicePlatform.Mobile, - }, - }), - ]); - - const userLoginData = await authService.doLogin(data.email, data.password, twoFactorCode); - - await dispatch( - authThunks.signInThunk({ - user: userLoginData.user, - newToken: userLoginData.newToken, - token: userLoginData.token, - }), - ) - .unwrap() - .then(() => props.onFormSubmitSuccess?.()); - } catch (err) { - const castedError = errorService.castError(err); - if (authService.isEmailAlreadyInUseError(castedError)) { - setCreateAccountError(CreateAccountError.EmailAlreadyInUse); - } else { - setCreateAccountError(strings.errors.generic.title); - } - - analytics.track(AnalyticsEventKey.UserSignUpFailed, { - email: data.email, - message: castedError.message, - }); - setIsLoading(false); - } - })(); - }; - const handleTermsAndConditionsPress = () => { - Linking.openURL(appService.urls.termsAndConditions); - }; - useEffect(() => { - props.onFormLoadingChange?.(isLoading); - }, [isLoading]); - - return ( - <> - ( - { - field.onChange(text); - }} - status={getEmailError()} - onSubmitEditing={() => passwordInputRef.current?.focus()} - value={field.value} - style={tailwind('h-11')} - containerStyle={tailwind('mb-3')} - placeholder={strings.inputs.email} - maxLength={64} - returnKeyType="next" - keyboardType="email-address" - autoCapitalize="none" - autoComplete="off" - autoCorrect={false} - textContentType={'username'} - /> - )} - /> - - ( - ( - - - {showPassword ? ( - - ) : ( - - )} - - - )} - /> - )} - /> - - {props.renderActionsContainer({ onSubmitButtonPressed, isLoading, isValid, isDirty })} - - - - - - {strings.messages.termsAndConditions[0]}{' '} - - - {strings.messages.termsAndConditions[1]} - - - - - - - ); -}; - -const PasswordForgetReminder = () => { - const tailwind = useTailwind(); - return ( - - - - {strings.screens.SignUpScreen.security_subtitle[0]} - - {' '} - {strings.screens.SignUpScreen.security_subtitle[1]} - {' '} - {strings.screens.SignUpScreen.security_subtitle[2]} - - - ); -}; - -export default SignUpForm; diff --git a/src/navigation/LinkingConfiguration.ts b/src/navigation/LinkingConfiguration.ts index b2b83d076..735ca6c38 100644 --- a/src/navigation/LinkingConfiguration.ts +++ b/src/navigation/LinkingConfiguration.ts @@ -13,7 +13,6 @@ const linking: LinkingOptions = { screens: { Debug: 'debug', SignIn: 'sign-in', - SignUp: 'sign-up', TabExplorer: 'tab-explorer', ForgotPassword: 'forgot-password', WebLogin: 'login-success', diff --git a/src/navigation/RootNavigator.tsx b/src/navigation/RootNavigator.tsx index ab46a778a..82ae7dbd8 100644 --- a/src/navigation/RootNavigator.tsx +++ b/src/navigation/RootNavigator.tsx @@ -7,7 +7,6 @@ import { View } from 'react-native'; import { uiActions } from 'src/store/slices/ui'; import ForgotPasswordScreen from '../screens/ForgotPasswordScreen'; import SignInScreen from '../screens/SignInScreen'; -import SignUpScreen from '../screens/SignUpScreen'; import WebLoginScreen from '../screens/WebLoginScreen'; import { useAppDispatch, useAppSelector } from '../store/hooks'; import { driveActions } from '../store/slices/drive'; @@ -72,13 +71,6 @@ function AppNavigator(): JSX.Element { return ( - diff --git a/src/screens/DeactivatedAccountScreen/DeactivatedAccountScreen.tsx b/src/screens/DeactivatedAccountScreen/DeactivatedAccountScreen.tsx index 55ae19ad2..f17c69361 100644 --- a/src/screens/DeactivatedAccountScreen/DeactivatedAccountScreen.tsx +++ b/src/screens/DeactivatedAccountScreen/DeactivatedAccountScreen.tsx @@ -8,9 +8,10 @@ import { useTailwind } from 'tailwind-rn'; import { CheckCircle } from 'phosphor-react-native'; import AppText from 'src/components/AppText'; import strings from 'assets/lang/strings'; -import { Dimensions, View } from 'react-native'; +import { Dimensions, Linking, View } from 'react-native'; import AppVersionWidget from 'src/components/AppVersionWidget'; import { LinearGradient } from 'expo-linear-gradient'; +import appService from 'src/services/AppService'; export function DeactivatedAccountScreen({ navigation }: RootStackScreenProps<'DeactivatedAccount'>): JSX.Element { const tailwind = useTailwind(); @@ -18,8 +19,12 @@ export function DeactivatedAccountScreen({ navigation }: RootStackScreenProps<'D const handleGoToSignIn = () => { navigation.replace('SignIn'); }; - const handleGoToSignUp = () => { - navigation.replace('SignUp'); + const handleGoToSignUp = async () => { + const webAuthUrl = appService.urls.webAuth.signup; + const canOpen = await Linking.canOpenURL(webAuthUrl); + if (canOpen) { + await Linking.openURL(webAuthUrl); + } }; const dimensions = Dimensions.get('screen'); return ( diff --git a/src/screens/SignUpScreen/index.tsx b/src/screens/SignUpScreen/index.tsx deleted file mode 100644 index 947e40eaf..000000000 --- a/src/screens/SignUpScreen/index.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { useKeyboard } from '@internxt-mobile/hooks/useKeyboard'; -import { ScrollView, View } from 'react-native'; -import { useTailwind } from 'tailwind-rn'; -import strings from '../../../assets/lang/strings'; -import AppButton from '../../components/AppButton'; -import AppScreen from '../../components/AppScreen'; -import AppText from '../../components/AppText'; -import AppVersionWidget from '../../components/AppVersionWidget'; -import SignUpForm from '../../components/forms/SignUpForm'; -import useGetColor from '../../hooks/useColor'; -import { RootStackScreenProps } from '../../types/navigation'; - -function SignUpScreen({ navigation }: RootStackScreenProps<'SignUp'>): JSX.Element { - const tailwind = useTailwind(); - const getColor = useGetColor(); - - const { keyboardShown } = useKeyboard(); - - const onGoToSignInButtonPressed = () => { - navigation.canGoBack() ? navigation.goBack() : navigation.replace('SignIn'); - }; - - const onFormSubmitSuccess = () => { - navigation.replace('TabExplorer', { screen: 'Home' }); - }; - - return ( - - - - - - - {strings.screens.SignUpScreen.title} - - - - ( - - )} - /> - - - - - {strings.screens.SignUpScreen.alreadyHaveAccount} - - - - - {keyboardShown ? null : } - - - ); -} - -export default SignUpScreen; diff --git a/src/services/AuthService.ts b/src/services/AuthService.ts index 62b66dcfd..cb38db209 100644 --- a/src/services/AuthService.ts +++ b/src/services/AuthService.ts @@ -1,28 +1,19 @@ import { internxtMobileSDKConfig } from '@internxt/mobile-sdk'; -import { Keys, Password, TwoFactorAuthQR } from '@internxt/sdk'; +import { TwoFactorAuthQR } from '@internxt/sdk'; import { StorageTypes } from '@internxt/sdk/dist/drive'; import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings'; import EventEmitter from 'events'; import jwtDecode from 'jwt-decode'; import { validateMnemonic } from 'react-native-bip39'; -import { decryptText, decryptTextWithKey, encryptText, encryptTextWithKey, passToHash } from '../helpers'; +import { decryptText, encryptText, encryptTextWithKey, passToHash } from '../helpers'; import AesUtils from '../helpers/aesUtils'; import { getHeaders } from '../helpers/headers'; import { AsyncStorageKey } from '../types'; import analytics, { AnalyticsEventKey } from './AnalyticsService'; import appService from './AppService'; import asyncStorageService from './AsyncStorageService'; -import { keysService } from './common/keys'; import { SdkManager } from './common/sdk/SdkManager'; -interface RegisterParams { - firstName: string; - lastName: string; - email: string; - password: string; - captcha: string; -} - enum AuthEventKey { Login = 'login', Logout = 'logout', @@ -64,56 +55,6 @@ class AuthService { } } - public async doLogin(email: string, password: string, tfaCode?: string) { - const loginResult = await this.sdk.authV2.loginWithoutKeys( - { - email, - password, - tfaCode, - }, - { - encryptPasswordHash(password: Password, encryptedSalt: string): string { - const salt = decryptText(encryptedSalt); - const hashObj = passToHash({ password, salt }); - return encryptText(hashObj.hash); - }, - async generateKeys(): Promise { - const keys = { - privateKeyEncrypted: '', - publicKey: '', - revocationCertificate: '', - ecc: { - privateKeyEncrypted: '', - publicKey: '', - }, - kyber: { - publicKey: '', - privateKeyEncrypted: '', - }, - }; - return keys; - }, - }, - ); - - loginResult.user.mnemonic = decryptTextWithKey(loginResult.user.mnemonic, password); - - if (loginResult.user.privateKey) { - const decryptedPrivateKey = keysService.decryptPrivateKey(loginResult.user.privateKey, password); - loginResult.user.privateKey = Buffer.from(decryptedPrivateKey).toString('base64'); - } - - // Get the refreshed tokens, they contain expiration, the ones returned - // on the login doesn't have expiration - const refreshedTokens = await this.refreshAuthToken(loginResult.newToken); - - if (!refreshedTokens?.token || !refreshedTokens?.newToken) throw new Error('Unable to refresh auth tokens'); - return { - ...loginResult, - token: refreshedTokens.token, - newToken: refreshedTokens.newToken, - }; - } public async handleWebLogin(params: { mnemonic: string; token: string; newToken: string; privateKey?: string }) { try { @@ -226,10 +167,6 @@ class AuthService { await this.sdk.authV2.sendUserDeactivationEmail(token); } - public async getNewBits(): Promise<{ mnemonic: string }> { - return this.sdk.usersV2WithoutToken.generateMnemonic(); - } - public async areCredentialsCorrect({ email, password }: { email: string; password: string }) { const plainSalt = await this.getSalt(email); const newToken = SdkManager.getInstance().getApiSecurity().newToken; @@ -239,26 +176,6 @@ class AuthService { return this.sdk.authV2.areCredentialsCorrect(hashedPassword, newToken) ?? false; } - public async doRegister(params: RegisterParams) { - const hashObj = passToHash({ password: params.password }); - const encPass = encryptText(hashObj.hash); - const encSalt = encryptText(hashObj.salt); - const bits = await this.getNewBits(); - const mnemonic = bits.mnemonic; - const encMnemonic = encryptTextWithKey(mnemonic, params.password); - - const payload = { - email: params.email.toLowerCase(), - name: params.firstName, - lastname: params.lastName, - password: encPass, - mnemonic: encMnemonic, - salt: encSalt, - captcha: params.captcha, - }; - - return this.sdk.authV2.registerWithoutKeys(payload); - } public generateNew2FA(): Promise { const newToken = SdkManager.getInstance().getApiSecurity().newToken; diff --git a/src/types/navigation.ts b/src/types/navigation.ts index 2ea96fcbf..b27ec73a9 100644 --- a/src/types/navigation.ts +++ b/src/types/navigation.ts @@ -12,7 +12,6 @@ declare global { export type RootStackParamList = { Debug: undefined; - SignUp: undefined; SignIn: undefined; WebLogin: { mnemonic?: string; diff --git a/src/types/ui.ts b/src/types/ui.ts index 0e6f01b57..479bdb5c4 100644 --- a/src/types/ui.ts +++ b/src/types/ui.ts @@ -14,11 +14,6 @@ export interface BaseFormProps { }) => JSX.Element; } -export interface SignUpFormData { - email: string; - password: string; -} - export interface ChangePasswordFormData { newPassword: string; confirmNewPassword: string; From ac53d65027594322217ff75423b423a2535c14f7 Mon Sep 17 00:00:00 2001 From: Ramon Candel Date: Thu, 16 Oct 2025 09:36:15 +0200 Subject: [PATCH 2/2] Removed change password feature (only logic, not ui) --- .../forms/ChangePasswordForm/index.tsx | 33 +++++----- src/services/AuthService.ts | 64 +------------------ src/store/slices/auth/index.ts | 48 +++++++------- 3 files changed, 41 insertions(+), 104 deletions(-) diff --git a/src/components/forms/ChangePasswordForm/index.tsx b/src/components/forms/ChangePasswordForm/index.tsx index 1918bdba5..4ea491507 100644 --- a/src/components/forms/ChangePasswordForm/index.tsx +++ b/src/components/forms/ChangePasswordForm/index.tsx @@ -1,23 +1,22 @@ +import { yupResolver } from '@hookform/resolvers/yup'; +import { auth } from '@internxt/lib'; import { Eye, EyeSlash } from 'phosphor-react-native'; -import { Controller, useForm, useWatch } from 'react-hook-form'; import { useMemo, useState } from 'react'; +import { Controller, useForm, useWatch } from 'react-hook-form'; import { TouchableWithoutFeedback, View } from 'react-native'; import { useTailwind } from 'tailwind-rn'; -import { yupResolver } from '@hookform/resolvers/yup'; import * as yup from 'yup'; import strings from '../../../../assets/lang/strings'; import useGetColor from '../../../hooks/useColor'; +import { useAppSelector } from '../../../store/hooks'; import { BaseFormProps, ChangePasswordFormData } from '../../../types/ui'; import AppTextInput from '../../AppTextInput'; import StrengthMeter from '../../StrengthMeter'; -import { auth } from '@internxt/lib'; -import { useAppDispatch, useAppSelector } from '../../../store/hooks'; -import { authThunks } from 'src/store/slices/auth'; const ChangePasswordForm = (props: BaseFormProps) => { const tailwind = useTailwind(); const getColor = useGetColor(); - const dispatch = useAppDispatch(); + const [isLoading, setIsLoading] = useState(false); const [showNewPassword, setShowNewPassword] = useState(false); const [showConfirmNewPassword, setShowConfirmNewPassword] = useState(false); @@ -89,17 +88,17 @@ const ChangePasswordForm = (props: BaseFormProps) => { }; const onSubmitButtonPressed = handleSubmit((data) => { setIsLoading(true); - dispatch(authThunks.changePasswordThunk({ newPassword: data.newPassword })) - .unwrap() - .then(() => { - props.onFormSubmitSuccess?.(); - setValue('newPassword', ''); - setValue('confirmNewPassword', ''); - }) - .catch(() => undefined) - .finally(() => { - setIsLoading(false); - }); + // dispatch(authThunks.changePasswordThunk({ newPassword: data.newPassword })) + // .unwrap() + // .then(() => { + // props.onFormSubmitSuccess?.(); + // setValue('newPassword', ''); + // setValue('confirmNewPassword', ''); + // }) + // .catch(() => undefined) + // .finally(() => { + // setIsLoading(false); + // }); }); return ( diff --git a/src/services/AuthService.ts b/src/services/AuthService.ts index cb38db209..f4a14b6d8 100644 --- a/src/services/AuthService.ts +++ b/src/services/AuthService.ts @@ -1,12 +1,10 @@ import { internxtMobileSDKConfig } from '@internxt/mobile-sdk'; import { TwoFactorAuthQR } from '@internxt/sdk'; -import { StorageTypes } from '@internxt/sdk/dist/drive'; import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings'; import EventEmitter from 'events'; import jwtDecode from 'jwt-decode'; import { validateMnemonic } from 'react-native-bip39'; -import { decryptText, encryptText, encryptTextWithKey, passToHash } from '../helpers'; -import AesUtils from '../helpers/aesUtils'; +import { decryptText, encryptText, passToHash } from '../helpers'; import { getHeaders } from '../helpers/headers'; import { AsyncStorageKey } from '../types'; import analytics, { AnalyticsEventKey } from './AnalyticsService'; @@ -55,7 +53,6 @@ class AuthService { } } - public async handleWebLogin(params: { mnemonic: string; token: string; newToken: string; privateKey?: string }) { try { const mnemonic = Buffer.from(params.mnemonic, 'base64').toString('utf-8'); @@ -101,64 +98,6 @@ class AuthService { await internxtMobileSDKConfig.destroy(); } - public async doChangePassword(params: { - password: string; - newPassword: string; - }): Promise<{ token: string; newToken: string }> { - const { credentials } = await this.getAuthCredentials(); - const user = await asyncStorageService.getUser(); - - if (!credentials) throw new Error('User credentials not found'); - const salt = await this.getSalt(credentials.user.email); - - if (!salt) { - throw new Error('Internal server error. Please try later.'); - } - const hashedCurrentPassword = passToHash({ password: params.password, salt }).hash; - const encCurrentPass = encryptText(hashedCurrentPassword); - - const hashedNewPassword = passToHash({ password: params.newPassword }); - const encNewPass = encryptText(hashedNewPassword.hash); - const encryptedNewSalt = encryptText(hashedNewPassword.salt); - - const encryptedMnemonic = encryptTextWithKey(credentials.user.mnemonic, params.newPassword); - let privateKeyFinalValue; - if (credentials.user.privateKey) { - const privateKey = Buffer.from(credentials.user.privateKey, 'base64').toString(); - const privateKeyEncrypted = AesUtils.encrypt(privateKey, params.newPassword); - privateKeyFinalValue = privateKeyEncrypted; - } else { - /** - * We are not generating the public/private key in mobile - * so could be possible that the user doesn't has one associated - * in that case, we send this value - */ - privateKeyFinalValue = 'MISSING_PRIVATE_KEY'; - } - - const keys = user.keys; - const kyberKeys = keys.kyber; - const eccKeys = keys.ecc; - - const changePasswordResult = await this.sdk.usersV2.changePassword({ - currentEncryptedPassword: encCurrentPass, - newEncryptedSalt: encryptedNewSalt, - encryptedMnemonic, - newEncryptedPassword: encNewPass, - encryptedPrivateKey: privateKeyFinalValue, - keys: { - encryptedPrivateKey: eccKeys.privateKey, - encryptedPrivateKyberKey: kyberKeys.privateKey, - }, - encryptVersion: StorageTypes.EncryptionVersion.Aes03, - }); - - return { - token: changePasswordResult.token, - newToken: changePasswordResult.newToken, - }; - } - public reset(email: string): Promise { return this.sdk.authV2.sendChangePasswordEmail(email); } @@ -176,7 +115,6 @@ class AuthService { return this.sdk.authV2.areCredentialsCorrect(hashedPassword, newToken) ?? false; } - public generateNew2FA(): Promise { const newToken = SdkManager.getInstance().getApiSecurity().newToken; return this.sdk.authV2.generateTwoFactorAuthQR(newToken); diff --git a/src/store/slices/auth/index.ts b/src/store/slices/auth/index.ts index 0bba27e45..f72c4aa1d 100644 --- a/src/store/slices/auth/index.ts +++ b/src/store/slices/auth/index.ts @@ -331,30 +331,30 @@ export const changePasswordThunk = createAsyncThunk { const { sessionPassword } = getState().auth; if (!sessionPassword) throw new Error('No session password found'); - const { token, newToken } = await authService.doChangePassword({ - password: sessionPassword, - newPassword: newPassword, - }); - - if (!token || !newToken) throw new Error('No tokens found, this is fatal'); - - await asyncStorageService.saveItem(AsyncStorageKey.Token, token); - await asyncStorageService.saveItem(AsyncStorageKey.PhotosToken, newToken); - const user = getState().auth.user; - if (!user) throw new Error('No user found, this is fatal'); - - SdkManager.setApiSecurity({ - token, - newToken, - }); - - dispatch( - authActions.setSignInData({ - token: token, - photosToken: newToken, - user, - }), - ); + // const { token, newToken } = await authService.doChangePassword({ + // password: sessionPassword, + // newPassword: newPassword, + // }); + + // if (!token || !newToken) throw new Error('No tokens found, this is fatal'); + + // await asyncStorageService.saveItem(AsyncStorageKey.Token, token); + // await asyncStorageService.saveItem(AsyncStorageKey.PhotosToken, newToken); + // const user = getState().auth.user; + // if (!user) throw new Error('No user found, this is fatal'); + + // SdkManager.setApiSecurity({ + // token, + // newToken, + // }); + + // dispatch( + // authActions.setSignInData({ + // token: token, + // photosToken: newToken, + // user, + // }), + // ); dispatch(authActions.setSessionPassword(newPassword)); }, );