This commit is contained in:
parent
a8f7189cb3
commit
ccfa28877c
|
@ -3,16 +3,28 @@ import * as dotenv from 'dotenv';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the password gives admin privileges (view / create / edit / delete)
|
||||||
|
* @param password
|
||||||
|
*/
|
||||||
export const checkAdminPrivileges = (password: string) => {
|
export const checkAdminPrivileges = (password: string) => {
|
||||||
return password == process.env.ADMIN_CREDENTIAL;
|
return password == process.env.ADMIN_CREDENTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the password gives member view privileges
|
||||||
|
* @param password
|
||||||
|
*/
|
||||||
export const checkMemberPrivileges = (password: string) => {
|
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) => {
|
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) => {
|
export const hasAccess = (calendarName: string, password: string) => {
|
||||||
|
|
|
@ -244,7 +244,7 @@ eventsRouter.delete('/:eventId', async (req: Request, res: Response) => {
|
||||||
let success = await EventService.deleteEvent(event);
|
let success = await EventService.deleteEvent(event);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send({'message': 'Event was successfully updated'});
|
res.status(200).send({'message': 'Event was successfully deleted'});
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({'message': 'An error occurred during deletion. Please try again.'});
|
res.status(500).send({'message': 'An error occurred during deletion. Please try again.'});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user