Skip to content

Commit

Permalink
Add documentation for setting/removing admins (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhtMinceraft1010X authored Nov 8, 2023
1 parent c10ce9a commit 583c3b4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion services/admin-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,47 @@ This will read in a file named `.env` for environment variables. Therefore, your
FIREBASE_SERVICE_ACCOUNT
```

This corresponds to the service account for the project on Firebase itself.
This corresponds to the service account for the project's development environment on Firebase itself.

## How to add/remove admin rights for users on the application

1. Run the command below. This will start up the admin service locally:
```shell
dotenv -e <insert full path of env file> -c development -- yarn dev
```

Although the command is `dev`, the Firebase admin rights can also be added to/removed from the users on the production
or development version of the application. This is because the users and roles are stored remotely on Firebase.

The application version affected depends on the value of
the `FIREBASE_SERVICE_ACCOUNT` environment variable in `<insert full path of env file>`.

Hence, if your `FIREBASE_SERVICE_ACCOUNT` environment variable has the service account for the production application,
the admin rights will be added to users registered in the production app.

1. To set admin rights on a user, make a `PUT` request with `uid` corresponding to the user's uid in the Firebase project
corresponding to the application version. You can do this using a tool like [Postman](https://www.postman.com/),
which you need to install separately.

```
http://localhost:5005/api/admin-service/setAdmin/<uid>
```

![Set Admin Example](./setAdminExample.png)

1. To remove admin rights from the same user, make a `PUT` request with the same `uid`.
```
http://localhost:5005/api/admin-service/removeAdmin/<uid>
```

### Shortcut

If you are setting/removing admin rights for users on the dev environment, you can simply run:
```shell
yarn workspace admin-service dev:local
```

This uses the default `.env` file which has a `FIREBASE_SERVICE_ACCOUNT` corresponding to the development app.

## How to do automated testing
Automated testing is done using a [Firebase Local Emulator Suite](https://firebase.google.com/docs/emulator-suite).
Expand Down
Binary file added services/admin-service/setAdminExample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 583c3b4

Please sign in to comment.