Closed rwx-yxu closed 1 year ago
Investigate firebase API - for email activation
Might be on the slides. I would like an example piece of code here as demo.
Register component. User will need to insert name, address, phone number, institutional affiliation, email and password. (Items which are bold are required)
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
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.
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
Probably would want email validation using regular expressions.
Starting with the happy path first. For dev, use your own firebase project instance and auth.
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.
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.
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.
Summary
A user must register a username and password to access the system
Basic Path
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