start building controller module
This commit is contained in:
parent
8cf5edb0bb
commit
9557b613f1
1 changed files with 30 additions and 0 deletions
30
src/Control/Settings.hs
Normal file
30
src/Control/Settings.hs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
module Control.Settings where
|
||||||
|
|
||||||
|
import Control.Monad.Reader
|
||||||
|
|
||||||
|
import Servant
|
||||||
|
|
||||||
|
-- internal imports
|
||||||
|
|
||||||
|
import Types
|
||||||
|
import Model.Settings
|
||||||
|
import Util (checkCapability)
|
||||||
|
|
||||||
|
getSettings
|
||||||
|
:: Maybe (Int, AuthMethod)
|
||||||
|
-> MateHandler Settings
|
||||||
|
getSettings Nothing = do
|
||||||
|
throwError $ err401
|
||||||
|
{ errBody = "No authentication present"
|
||||||
|
}
|
||||||
|
getSettings (Just (uid, method)) = do
|
||||||
|
isManager <- checkCapability uid roleCanManageSettings
|
||||||
|
if method `elem` [PrimaryPass, ChallengeResponse] && isManager
|
||||||
|
then do
|
||||||
|
conn <- asks rsConnection
|
||||||
|
selectSettings conn
|
||||||
|
else
|
||||||
|
throwError $ err401
|
||||||
|
{ errBody = "Wrong Authentication present"
|
||||||
|
}
|
Loading…
Reference in a new issue