Skip to content

User Login & Authentication

Martha Sharpe edited this page Jan 23, 2021 · 7 revisions

User authentication for this app begins in the navigation folder with AuthNavigator. This determines whether to show the Dashboard or the Login Screen when the app is opened.

Auto Login

As soon as the user opens the app, an action is called to see if there is a valid access token stored on the device in SecureStore.

If there is a valid access token, the user is automatically logged in and taken to the main navigation stack. If not, they remain on the login screen. If there is an expired token, they are logged out via the api middleware and returned to the login screen. The user sees a loading spinner until this is resolved.

Login Screen

The user must enter something in the email and password fields. Otherwise the form will not submit and a red error text will appear asking them to provide their email and/or password.

If the user submits the form with an email and password, a request to login will be sent to the api. If the login fails, the user will see the error message 'Invalid email or password.' If it succeeds, the user's info will be fetched from the api.

In the AuthNavigator, if the logged in user has no DSPR drivers associated with their account, they will be logged out and notified that they must be a driver to use this app.

Clone this wiki locally