diff options
Diffstat (limited to 'src/screens/onboarding/Login.tsx')
| -rw-r--r-- | src/screens/onboarding/Login.tsx | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx index 6d9d3a97..49ca5ff4 100644 --- a/src/screens/onboarding/Login.tsx +++ b/src/screens/onboarding/Login.tsx @@ -27,7 +27,7 @@ import { import {OnboardingStackParams} from '../../routes/onboarding'; import {fcmService} from '../../services'; import {RootState} from '../../store/rootReducer'; -import {BackgroundGradientType} from '../../types'; +import {BackgroundGradientType, UniversityType} from '../../types'; import {normalize, userLogin} from '../../utils'; import UpdateRequired from './UpdateRequired'; @@ -156,18 +156,39 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { let statusCode = response.status; let data = await response.json(); + if (statusCode === 200) { + await AsyncStorage.setItem('token', data.token); + await AsyncStorage.setItem('userId', data.UserID); + await AsyncStorage.setItem('username', username); + } + if (statusCode === 200 && data.isOnboarded) { //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); userLogin(dispatch, {userId: data.UserID, username}); fcmService.sendFcmTokenToServer(); } catch (err) { Alert.alert(ERROR_INVALID_LOGIN); } + } else if ( + statusCode === 200 && + data.university === UniversityType.Empty + ) { + /** + * A user account was created during onboarding step 2 but user didn't + * finish step 3, thus does not have a universtiy. + * Redirecting user back to onboarding to finish the process + */ + navigation.navigate('OnboardingStepThree', { + userId: data.UserID, + username: username, + }); } else if (statusCode === 200 && !data.isOnboarded) { + /** + * A user account was created and finished the onboarding process but + * did not have an invitation code at the time so the user's account + * is not activated (isOnboarded) yet. + */ navigation.navigate('InvitationCodeVerification', { userId: data.UserID, username: username, @@ -242,6 +263,7 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { valid={form.isValidUser} invalidWarning="Username must be at least 6 characters and can only contain letters, numbers, periods, and underscores." attemptedSubmit={form.attemptedSubmit} + autoCorrect={false} /> <TaggInput @@ -259,6 +281,7 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { invalidWarning="Password must be at least 8 characters long." attemptedSubmit={form.attemptedSubmit} ref={inputRef} + autoCorrect={false} /> <ForgotPassword /> <TaggSquareButton |
