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:
access-token
client
uid (the email)
When a user signs in, a new client token is issued, along with an access-token the specifically matches that client.
Test Data
Can create a new user
An existing user details are
email: test@gmail.com
password: password
Callouts
At the moment the backend is not regenerating the access tokens each request. We can do this down the track to make it a bit more secure.
There has been no design effort put into this as we don't have designs yet
This is authenticating against the real backend. We aren't using users for any particular purpose yet, but just note this in case you were about to start attempting SQL injections or something...
Still need to actually validate that the token is still valid
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:
access-token
client
uid
(the email)When a user signs in, a new
client
token is issued, along with anaccess-token
the specifically matches that client.Test Data
Callouts
Screenshots