Skip to content

API side Login and Signup flow

Sunil Sonawane edited this page Apr 20, 2020 · 1 revision

Required data entries

  1. Should have one organisation entry in organisations table with valid domain name.
  2. Roles table should have three roles Admin, Employee and Moderator in it.

Execution flow

  1. Client will collect google-auth-token received from google signin.
  2. Client will initiate POST request for login to Node API with google-auth-token in request body.
  3. API should authenticate this google-auth-token with google services and fetch user profile.
  4. Fetch email from user profile and check if user with this email id exists in users table.
  5. If user is present in database and is not soft deleted, generate jwt token and send in the response along with user role.
  6. If user is not present in database, then fetch domain of user email from user profile.
  7. Check if organisation with that domain exists in database.
  8. If organisation exists with that domain, add that user in users table and generate and send jwt token in response along with user role. (For new user signing up back end should add "Employee" as user role. Note: We need to finalise how can we add user as moderator.)
  9. If user domain is not matching with any organisation, simple return 401.