From 6aa3bf3068d60f5ffac5af43ed98175e4735903f Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 2 Nov 2020 13:23:04 -0500 Subject: added async storage login for userid and username (#89) --- src/screens/onboarding/Login.tsx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/screens') diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx index 8ff7ebc2..3fe857cd 100644 --- a/src/screens/onboarding/Login.tsx +++ b/src/screens/onboarding/Login.tsx @@ -1,23 +1,22 @@ -import React, {useRef, useState} from 'react'; +import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; +import React, {useRef, useState} from 'react'; import { - View, - Text, Alert, - StatusBar, Image, - TouchableOpacity, - StyleSheet, KeyboardAvoidingView, Platform, + StatusBar, + StyleSheet, + Text, + TouchableOpacity, + View, } from 'react-native'; - -import {OnboardingStackParams} from '../../routes/onboarding'; +import {Background, SubmitButton, TaggInput} from '../../components'; +import {LOGIN_ENDPOINT, usernameRegex} from '../../constants'; import {AuthContext} from '../../routes/authentication'; -import {Background, TaggInput, SubmitButton} from '../../components'; -import {usernameRegex, LOGIN_ENDPOINT} from '../../constants'; -import AsyncStorage from '@react-native-community/async-storage'; +import {OnboardingStackParams} from '../../routes/onboarding'; import {UserType} from '../../types'; type VerificationScreenRouteProp = RouteProp; @@ -137,6 +136,8 @@ const Login: React.FC = ({navigation}: LoginProps) => { //Stores token received in the response into client's AsynStorage try { await AsyncStorage.setItem('token', data.token); + await AsyncStorage.setItem('userId', data.UserID); + await AsyncStorage.setItem('username', username); login(data.UserID, username); } catch (err) { setUser(NO_USER); -- cgit v1.2.3-70-g09d2