lpr: add system function printer
This commit is contained in:
parent
5c2281bd29
commit
841936178d
@ -53,9 +53,9 @@ UserFunction -- Administratively assigned functions (lecturer, admin, evaluation
|
|||||||
deriving Generic
|
deriving Generic
|
||||||
UserSystemFunction
|
UserSystemFunction
|
||||||
user UserId
|
user UserId
|
||||||
function SystemFunction
|
function SystemFunction -- Defined in Model.Types.User
|
||||||
manual Bool
|
manual Bool -- Inserted manually by Admin or automatic from LDAP
|
||||||
isOptOut Bool
|
isOptOut Bool -- User has currently deactivate the role for themselves
|
||||||
UniqueUserSystemFunction user function
|
UniqueUserSystemFunction user function
|
||||||
deriving Generic
|
deriving Generic
|
||||||
UserExamOffice
|
UserExamOffice
|
||||||
|
|||||||
2
routes
2
routes
@ -9,6 +9,8 @@
|
|||||||
--
|
--
|
||||||
-- Admins always have access to entities within their assigned schools.
|
-- Admins always have access to entities within their assigned schools.
|
||||||
--
|
--
|
||||||
|
-- Access tags are defined in Model.Types.Security
|
||||||
|
--
|
||||||
-- Access Tags:
|
-- Access Tags:
|
||||||
-- !free -- free for all
|
-- !free -- free for all
|
||||||
-- !lecturer -- lecturer for this course (or for any school, if route is not connected to a course)
|
-- !lecturer -- lecturer for this course (or for any school, if route is not connected to a course)
|
||||||
|
|||||||
@ -555,6 +555,15 @@ tagAccessPredicate AuthSystemExamOffice = cacheAPSystemFunction SystemExamOffice
|
|||||||
isExamOffice <- lift $ exists [UserSystemFunctionUser ==. authId, UserSystemFunctionFunction ==. SystemExamOffice, UserSystemFunctionIsOptOut ==. False]
|
isExamOffice <- lift $ exists [UserSystemFunctionUser ==. authId, UserSystemFunctionFunction ==. SystemExamOffice, UserSystemFunctionIsOptOut ==. False]
|
||||||
guardMExceptT isExamOffice $ unauthorizedI MsgUnauthorizedSystemExamOffice
|
guardMExceptT isExamOffice $ unauthorizedI MsgUnauthorizedSystemExamOffice
|
||||||
return Authorized
|
return Authorized
|
||||||
|
tagAccessPredicate AuthSystemPrinter = cacheAPSystemFunction SystemPrinter (Just $ Right diffHour) $ \mAuthId' _ _ printerList -> if
|
||||||
|
| maybe True (`Set.notMember` printerList) mAuthId' -> Right $ if
|
||||||
|
| is _Nothing mAuthId' -> return AuthenticationRequired
|
||||||
|
| otherwise -> unauthorizedI MsgUnauthorizedSystemPrinter
|
||||||
|
| otherwise -> Left $ APDB $ \_ _ mAuthId _ _ -> $cachedHereBinary mAuthId . exceptT return return $ do
|
||||||
|
authId <- maybeExceptT AuthenticationRequired $ return mAuthId
|
||||||
|
isPrinter <- lift $ exists [UserSystemFunctionUser ==. authId, UserSystemFunctionFunction ==. SystemPrinter, UserSystemFunctionIsOptOut ==. False]
|
||||||
|
guardMExceptT isPrinter $ unauthorizedI MsgUnauthorizedSystemPrinter
|
||||||
|
return Authorized
|
||||||
tagAccessPredicate AuthStudent = cacheAPSystemFunction SystemStudent (Just $ Right diffHour) $ \mAuthId' _ _ studentList -> if
|
tagAccessPredicate AuthStudent = cacheAPSystemFunction SystemStudent (Just $ Right diffHour) $ \mAuthId' _ _ studentList -> if
|
||||||
| maybe True (`Set.notMember` studentList) mAuthId' -> Right $ if
|
| maybe True (`Set.notMember` studentList) mAuthId' -> Right $ if
|
||||||
| is _Nothing mAuthId' -> return AuthenticationRequired
|
| is _Nothing mAuthId' -> return AuthenticationRequired
|
||||||
|
|||||||
@ -11,6 +11,7 @@ data SystemFunction
|
|||||||
= SystemExamOffice
|
= SystemExamOffice
|
||||||
| SystemFaculty
|
| SystemFaculty
|
||||||
| SystemStudent
|
| SystemStudent
|
||||||
|
| SystemPrinter
|
||||||
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable)
|
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable)
|
||||||
deriving anyclass (Universe, Finite, Hashable, NFData)
|
deriving anyclass (Universe, Finite, Hashable, NFData)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user