advweb-grp1 / advanced-web-final-year-project

Final year advanced web develop unit project
MIT License
1 stars 0 forks source link

Register User #7

Closed rwx-yxu closed 1 year ago

rwx-yxu commented 1 year ago

Summary

A user must register a username and password to access the system

Basic Path

  1. The use case starts when a user indicates that he/she wants to register.
  2. The system requests a username (must be an email address) and password.
  3. The user enters a username and password.
  4. The system checks that the username does not duplicate any existing registered usernames.
  5. The system requests a name (), address, phone number, institutional affiliation () and email address (). Items marked by () are required.
  6. The user enters the information.
  7. The system determines the user's location and stores all user information.
  8. The system sends a verification email with a verification link to the user’s email address.
  9. User clicks on link in email address.
  10. User is redirected to a login page.
  11. User logs in.
  12. The system starts a login session and displays a welcome message.

    Alternative Paths

    Step 4: If the username duplicates an existing username, the system displays a message and the use case goes back to step 2. Step 5: If the user does not enter a required field, a message is displayed and the use case repeats step 4.

    Exception Paths

    User already exists, in which case he/she can enter their password if known or request a password reset.

    Preconditions

    The username is the user’s email address.

    Postconditions

    The user can now access the system to add data, delete data, query data and visualise data

advweb-grp1 commented 1 year ago

Investigate firebase API - for email activation

advweb-grp1 commented 1 year ago

Might be on the slides. I would like an example piece of code here as demo.

AymanReh commented 1 year ago

Register component. User will need to insert name, address, phone number, institutional affiliation, email and password. (Items which are bold are required)

AymanReh commented 1 year ago

Register authentication

Validating data

User session

If a user is already logged in they should not be able to see the register button, this can be done by checking their session state

Testing

Unit tests that could be implemented include a test for validating user data such as when entering a phone number ensuring that it always begins with a + e.g. +447123456789 will pass the test, but 07123456789 will fail. E2E testing may include a process of entering an email which are already inside of the database to ensure that duplicate data cannot be entered. Another E2E test may include completing the form and ensuring that the users account has been created.

AymanReh commented 1 year ago

After doing some research on creating users in firebase, it seems like when a user creates an account using firebase they are automatically logged in. Source: https://firebase.google.com/docs/auth/web/password-auth#create_a_password-based_account image

advweb-grp1 commented 1 year ago

Probably would want email validation using regular expressions.

advweb-grp1 commented 1 year ago

Starting with the happy path first. For dev, use your own firebase project instance and auth.

AymanReh commented 1 year ago

After working on the register view it turns out that firebase automatically makes sure that there can be no duplicate data for the email, meaning no validation for duplicate email is required.

AymanReh commented 1 year ago

After implementing register user it seems like firebase only stores the email and password with the createUserWithEmailAndPassword command. So name, address, phone number and affiliation are not stored inside of the firebase authentication. Instead I can either store the data in a collection or store the data locally using something like a variable, but the problem is that it only stores the data on the users device instead of on firestore.

AymanReh commented 1 year ago

Ive updated feature/register to add user data to the database and added some validation for phone number. Now I need to add unit tests to test the register page.