aboutsummaryrefslogtreecommitdiff
path: root/src/screens/onboarding/Login.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-26 20:01:26 -0400
committerIvan Chen <ivan@tagg.id>2021-03-26 20:01:26 -0400
commited26661062a2e47df2662254eaddfcfa1de62d04 (patch)
tree78e1683c60ba65a1d71631838be500e1f54607f6 /src/screens/onboarding/Login.tsx
parent5b975a354f0707c0671571387d5bda501fbe75ae (diff)
parentbef5728b24a71d1bf327a72e425346020a997037 (diff)
Merge branch 'master' into tma-722-cornell-fe
# Conflicts: # src/types/types.ts
Diffstat (limited to 'src/screens/onboarding/Login.tsx')
-rw-r--r--src/screens/onboarding/Login.tsx29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx
index 6d9d3a97..97f4fe87 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,