Users need to be able to update their accounts with a Github URL.
Acceptance criteria
Login as any user
Navigate to the user account view
/account
Observe view includes the following:
Update Github URL: <input>
Button to update the user's Github URL
Technical requirements
Account template updates to include new design
Account component update to interact with the state
Account state management updated to interact with API
onUpdateAccount HTTPS callable function to update the /users/{{uid}} document with new Github URL property
Type of function
For this update, we will be creating an HTTPS callable function that allows users to update their account information directly from the application.
Additional types of functions can be reviewed here: Cloud Functions
Create onUpdateAccount function
In the apps\full-stack-typescript-api\src\functions folder, create the following:
Updateapps\full-stack-typescript-api\src\functions\account\index.ts to be:
The new function receives a data payload of type User and merges the new data to the users document in our database.
Updateapps\full-stack-typescript-api\src\main.ts to include the new function.
The main.ts file is our primary entry point for our functions and needs to be updated so that our new function is included when the project is built.
Build the functions
Run the following command to build the functions application:
nx build full-stack-typescript-api
Deploy functions
Run the following command to deploy new and updated functions:
firebase deploy --only functions
Update the frontend application for new API interaction
Now that we've created a secure method for interacting with the database, we need to update the frontend application to integrate with the new function.
Update Account state management
Update actions
Updatelibs\features\account\src\lib\+state\account.actions.ts to include the new actions:
updateAccount
updateAccountFailure
updateAccountSuccess
Update reducer
Updatelibs\features\account\src\lib\+state\account.reducer.ts to include:
Update facade
Updatelibs\features\account\src\lib\+state\account.facade.ts to include:
Update effects
Updatelibs\features\account\src\lib\+state\account.effects.ts to include:
Update AccountService
Updatelibs\services\account\src\lib\account.service.ts to include:
Update AccountModule for forms integration
Updatelibs\features\account\src\lib\account.module.ts to include the FormsModule :
Update AccountComponent class
Updatelibs\features\account\src\lib\account.component.ts to include:
Update AccountComponent template
Updatelibs\features\account\src\lib\account.component.html to include:
Further improvements
There is now a secure way for users to update their account information with the database. The onUpdateAccount function and Account state accepts a User payload which can include all of the attributes of User.
The AccountComponent can be improved to enable updating of all User properties.