diff options
author | Shravya Ramesh <37447613+shravyaramesh@users.noreply.github.com> | 2020-10-07 23:06:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 02:06:32 -0400 |
commit | 45e435dbb4c43cb890eb360413784d0b2e331bc5 (patch) | |
tree | caa1df04c7b5fcc70ba2c48fa780a4cf2d8e5e0d /src/screens/onboarding/RegistrationThree.tsx | |
parent | 0f332655d2b64700623f25912d2610517fb954b6 (diff) |
[TMA 68] Frontend Token Security (#43)
* frontend tma-68 token security
* removed: try catch while storing token to async, unnecessary console.log
* login/registration exception handling and relocation
* Modified promises, applied fetch restriction
Diffstat (limited to 'src/screens/onboarding/RegistrationThree.tsx')
-rw-r--r-- | src/screens/onboarding/RegistrationThree.tsx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/screens/onboarding/RegistrationThree.tsx b/src/screens/onboarding/RegistrationThree.tsx index f8daaf71..5b8f52b3 100644 --- a/src/screens/onboarding/RegistrationThree.tsx +++ b/src/screens/onboarding/RegistrationThree.tsx @@ -28,6 +28,7 @@ import { Background, } from '../../components'; import {passwordRegex, usernameRegex, REGISTER_ENDPOINT} from '../../constants'; +import AsyncStorage from '@react-native-community/async-storage'; type RegistrationScreenThreeRouteProp = RouteProp< OnboardingStackParams, @@ -170,10 +171,15 @@ const RegistrationThree: React.FC<RegistrationThreeProps> = ({ let data = await registerResponse.json(); const userId: string = data.UserID; if (statusCode === 201) { - navigation.navigate('Checkpoint', { - userId: userId, - username: form.username, - }); + try { + await AsyncStorage.setItem('token', data.token); + navigation.navigate('Checkpoint', { + userId: userId, + username: form.username, + }); + } catch (err) { + console.log(err); + } } else if (statusCode === 409) { Alert.alert('Registration failed 😔', `${data}`); } else { |