expand controller module for the settings
This commit is contained in:
parent
9557b613f1
commit
71846b63cf
1 changed files with 21 additions and 1 deletions
|
@ -8,7 +8,7 @@ import Servant
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
import Model.Settings
|
import Model.Settings as Model
|
||||||
import Util (checkCapability)
|
import Util (checkCapability)
|
||||||
|
|
||||||
getSettings
|
getSettings
|
||||||
|
@ -28,3 +28,23 @@ getSettings (Just (uid, method)) = do
|
||||||
throwError $ err401
|
throwError $ err401
|
||||||
{ errBody = "Wrong Authentication present"
|
{ errBody = "Wrong Authentication present"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSettings
|
||||||
|
:: Maybe (Int, AuthMethod)
|
||||||
|
-> Settings
|
||||||
|
-> MateHandler NoContent
|
||||||
|
updateSettings Nothing _ =
|
||||||
|
throwError $ err401
|
||||||
|
{ errBody = "No authentication present"
|
||||||
|
}
|
||||||
|
updateSettings (Just (uid, method)) newSettings = do
|
||||||
|
isManager <- checkCapability uid roleCanManageSettings
|
||||||
|
if method `elem` [PrimaryPass, ChallengeResponse] && isManager
|
||||||
|
then do
|
||||||
|
conn <- asks rsConnection
|
||||||
|
void $ Model.updateSettings newSettings conn
|
||||||
|
return NoContent
|
||||||
|
else
|
||||||
|
throwError $ err401
|
||||||
|
{ errBody = "Wrong Authentication present"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue