carrythroughcovid / ctc-app

React Native app for CTC
0 stars 0 forks source link

Add Sign In and Sign Up Functionality #14

Closed peroh closed 4 years ago

peroh commented 4 years ago

Overview

Add a sign in and sign up screen before loading the main content. Main content now only accessible once a user has signed in.

Added a settings tab, that just has a logout button in it for now.

Tech Overview

Protected Routes

The MainNavigator.js file has most of the juiciness in it.

I updated all our navigation to use react-navigation 5, which allows for conditional logic inside of the navigator itself. This means we can hold some state about whether the user is logged in or not, and protect main routes if the user isn't logged in.

There is a reducer at the top level that works out what state the user is in, and this is provided to the rest of the app via a context.

Local Storage

Using React Natives AsyncStorage to store the users token information in local storage. This means that a user can stay logged in after closing and reopening the app.

Authentication

The backend does authentication using a mix of three bits of data:

When a user signs in, a new client token is issued, along with an access-token the specifically matches that client.

Test Data

email: test@gmail.com
password: password

Callouts

Screenshots

Screenshot_1588769926

Screenshot_1588769973

Screenshot_1588770003

shadforth commented 4 years ago

Noice! Will have a proper look tonight! 👌

shadforth commented 4 years ago

LGTM. Tested locally on iPhone emulator and working great. Noted on the callouts, too. 👍