Skip to content

Commit

Permalink
added documentation on admin manager
Browse files Browse the repository at this point in the history
  • Loading branch information
qiandrewj committed May 5, 2024
1 parent 2f27fa3 commit c5f04fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/src/modules/Admin/Components/ManageAdminModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const ManageAdminModal = ({token, open, setOpen}: Props) => {
setOpen(false)
}

/**
* Endpoint to get all admins
*/
useEffect(() => {
axios
.post('/api/getAdmins', {token: token})
Expand All @@ -33,6 +36,11 @@ const ManageAdminModal = ({token, open, setOpen}: Props) => {
})
}, [token])

/**
* Removes an admin from the list, giving that user 'regular' privilege
* @param user assumes that this user already has admin privilege
*/

function removeAdmin(user: Student) {
axios
.post('/api/removeAdmin', {
Expand All @@ -49,6 +57,11 @@ const ManageAdminModal = ({token, open, setOpen}: Props) => {
}).catch((e) => console.log(`Unable to remove admin ${e}`))
}

/**
* Calls endpoint to add or update a user with admin privilege
* @param _netId the user's net id
*/

function addAdminByNetId(_netId: string) {
axios
.post('/api/grantAdmin', {
Expand Down
5 changes: 5 additions & 0 deletions server/src/admin/admin.data-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export const grantAdminPrivilege = async (id: string) => {
return res
}

/*
* If there is an attempt to grant admin privilege to someone not in the database,
* a new user will be created with the given netid and added to the database.
*/

export const createNewAdminUser = async (id: string) => {

const admin: InsertStudentType = {
Expand Down

0 comments on commit c5f04fc

Please sign in to comment.