antville/code/Skin/securityFunctions.js
Robert Gaggl 4dc576c5e0 - added checkAccess() that is called by onRequest() to check if a user is allowed to request a certain action
- modified permission check methods: they now return an Exception object in case a certain action is denied
2003-08-02 12:12:34 +00:00

28 lines
717 B
JavaScript

/**
* permission check (called by hopobject.onRequest())
* @param String name of action
* @param Obj User object
* @param Int Membership level
* @return Obj Exception object or null
*/
function checkAccess(action, usr, level) {
checkIfLoggedIn(this.href(req.action));
var deny = this.isDeleteDenied(usr, level);
if (deny)
deny.redirectTo = this.site.skins.href();
return deny;
}
/**
* check if user is allowed to delete this skin
* @param Obj Userobject
* @param Int Permission-Level
* @return String Reason for denial (or null if allowed)
*/
function isDeleteDenied(usr, level) {
if ((level & MAY_EDIT_SKINS) == 0)
return new Exception("skinDeleteDenied");
return null;
}