Adjust privileges mgmt
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2022-12-25 18:24:18 +01:00
parent a8f7189cb3
commit ccfa28877c
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE
2 changed files with 15 additions and 3 deletions

View File

@ -3,16 +3,28 @@ import * as dotenv from 'dotenv';
dotenv.config();
/**
* Checks if the password gives admin privileges (view / create / edit / delete)
* @param password
*/
export const checkAdminPrivileges = (password: string) => {
return password == process.env.ADMIN_CREDENTIAL;
}
/**
* Checks if the password gives member view privileges
* @param password
*/
export const checkMemberPrivileges = (password: string) => {
return password == process.env.MEMBER_CREDENTIAL;
return password == process.env.MEMBER_CREDENTIAL || password == process.env.ADMIN_CREDENTIAL;
}
/**
* Checks if the password gives management view privileges
* @param password
*/
export const checkManagementPrivileges = (password: string) => {
return password == process.env.MANAGEMENT_CREDENTIAL;
return password == process.env.MANAGEMENT_CREDENTIAL || password == process.env.ADMIN_CREDENTIAL;
}
export const hasAccess = (calendarName: string, password: string) => {

View File

@ -244,7 +244,7 @@ eventsRouter.delete('/:eventId', async (req: Request, res: Response) => {
let success = await EventService.deleteEvent(event);
if (success) {
res.status(200).send({'message': 'Event was successfully updated'});
res.status(200).send({'message': 'Event was successfully deleted'});
} else {
res.status(500).send({'message': 'An error occurred during deletion. Please try again.'});
}