-
Ionic auth with express and mongoose
about 9 years ago
-
almost 9 years ago
To authenticate a user first you need to save the credentials to DB. When user login with valid credential then create a token and save this token to userSession collection into DB also you need to create session that store this token with user details.
For every request to API made by the user you need to sent this token along with the data. At the API end first validate the token. To validate token make a DB query on userSession collection. If the token is exist on collection perform further steps otherwise sent authentication fail response and redirect to sign in page.
-
1 Answer(s)