hackwitus / borrowIt

Point of Borrow application repository
MIT License
4 stars 4 forks source link

Use HarperDB's user/role system to create a simple auth system #16

Open Ethan-Arrowood opened 6 years ago

Ethan-Arrowood commented 6 years ago

~Combine with json web tokens and JSON web key sets to make a super secure API~ I'd love to do all that but it would require an additional server and I truly believe we can make BorrowIt "serverless"

Ethan-Arrowood commented 6 years ago

Idea 1:

User signs up using basic sign up form (Username (cannot be changed), Email (will not be changed except via an Admin override), Password (user can change at any time)) This data is sent to HDB with the add_user operation

If everything checks out* the callback function should dispatch a secondary insert operation that contains the username (hash_id) and the user's email. This is stored in a users table.

*Satisfies DB user rules (available username, syntactically acceptable password). The client will do a preliminary validation check of username, email, and password. ~Before add_user operation is sent, use an asynchronous username check against list_users.~ (Actually don't do this because then we gotta send a ton of data to the client and its unnecessary). The add_user operation will return an error if something goes wrong; share the error with the user appropriately.

The user is then asked to fill out some additional information:

Information provided is added to their user record in the users table. Their email is stored in this record as well.

When a user logs in successfully, create the Basic authorization token and store it in localstorage. Whenever the user makes a request from the client send the HarperDB request with their token.

Additional Details: