Commit f91f348e authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

wrwrwaesrg

parent 4c4bb4c3
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import {
} from "react";
import { UserInfoEntity } from "../domain/entities/user_info_entity";
import * as SecureStore from "expo-secure-store";
import AsyncStorage from "@react-native-async-storage/async-storage";
import axios from "axios";
import { UserPreferences } from "../../common/domain/entities/user_preferences";

@@ -43,7 +44,7 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => {
        const recoveredUser = JSON.parse(user) as UserInfoEntity;
        setUser(recoveredUser);
        const ssKey = recoveredUser.email.split("@")[0];
        const userPreferences = SecureStore.getItem(ssKey);
        const userPreferences = await AsyncStorage.getItem(ssKey);
        if (userPreferences) {
          const parsedUserPreferences = JSON.parse(
            userPreferences
@@ -54,7 +55,10 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => {
            isFirstTime: true,
            isVerifiedEmail: false,
          };
          SecureStore.setItem(ssKey, JSON.stringify(emptyUserPreferences));
          await AsyncStorage.setItem(
            ssKey,
            JSON.stringify(emptyUserPreferences)
          );
          setIsVerified(false);
        }
        axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
@@ -70,12 +74,12 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => {
  const verify = async () => {
    if (!user) return;
    const sskey = user.email.split("@")[0];
    const userPreferences = SecureStore.getItem(sskey);
    const userPreferences = await AsyncStorage.getItem(sskey);
    if (!userPreferences) return;
    const parsedUserPreferences = JSON.parse(
      userPreferences
    ) as UserPreferences;
    SecureStore.setItem(
    await AsyncStorage.setItem(
      sskey,
      JSON.stringify({ ...parsedUserPreferences, isVerifiedEmail: true })
    );
+8 −4
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import {
import * as SecureStore from "expo-secure-store";
import { useAuth } from "../../auth/contexts/auth_context";
import { UserPreferences } from "../domain/entities/user_preferences";
import AsyncStorage from "@react-native-async-storage/async-storage";

type SetUpContextType = {
  isLoading: boolean;
@@ -36,13 +37,13 @@ export const SetUpContextProvider = ({
      return;
    }
    const sskey = user.email.split("@")[0];
    const userPreferences = SecureStore.getItem(sskey);
    const userPreferences = await AsyncStorage.getItem(sskey);
    if (userPreferences) {
      const parsedUserPreferences = JSON.parse(
        userPreferences
      ) as UserPreferences;
      parsedUserPreferences.isFirstTime = false;
      SecureStore.setItem(sskey, JSON.stringify(parsedUserPreferences));
      await AsyncStorage.setItem(sskey, JSON.stringify(parsedUserPreferences));
      setIsFirstTime(false);
    }
    setIsLoading(false);
@@ -63,7 +64,7 @@ export const SetUpContextProvider = ({
          return;
        }
        const sskey = user.email.split("@")[0];
        const value = SecureStore.getItem(sskey);
        const value = await AsyncStorage.getItem(sskey);
        if (value) {
          const userPreferences = JSON.parse(value) as UserPreferences;
          setIsFirstTime(userPreferences.isFirstTime);
@@ -72,7 +73,10 @@ export const SetUpContextProvider = ({
            isFirstTime: true,
            isVerifiedEmail: false,
          };
          SecureStore.setItem(sskey, JSON.stringify(emptyUserPreferences));
          await AsyncStorage.setItem(
            sskey,
            JSON.stringify(emptyUserPreferences)
          );
        }
      } catch {
        console.log("Error checking session");