accept all, add admin role

This commit is contained in:
Filip Gralinski 2015-10-06 22:56:57 +02:00
parent 010d582eae
commit 5aba62400b
3 changed files with 10 additions and 2 deletions

View File

@ -63,7 +63,7 @@ isTrusted user =
"romang@amu.edu.pl" -> True
"junczys@amu.edu.pl" -> True
"rafalj@amu.edu.pl" -> True
_ -> False
_ -> True
@ -172,6 +172,7 @@ instance YesodAuth App where
{ userIdent = credsIdent creds
, userPassword = Nothing
, userName = Nothing
, userIsAdmin = False
}
-- You can add other plugins like BrowserID, email or OAuth here

View File

@ -33,7 +33,13 @@ postCreateChallengeR = do
_ -> Nothing
Just (name, publicUrl, publicBranch, privateUrl, privateBranch) = challengeData
runViewProgress $ doCreateChallenge name publicUrl publicBranch privateUrl privateBranch
userId <- requireAuthId
user <- runDB $ get404 userId
if userIsAdmin user
then
runViewProgress $ doCreateChallenge name publicUrl publicBranch privateUrl privateBranch
else
runViewProgress $ (flip err) "MUST BE AN ADMIN TO CREATE A CHALLENGE"
doCreateChallenge :: Text -> Text -> Text -> Text -> Text -> Channel -> Handler ()
doCreateChallenge name publicUrl publicBranch privateUrl privateBranch chan = do

View File

@ -3,6 +3,7 @@ User
password Text Maybe
UniqueUser ident
name Text Maybe
isAdmin Bool default=True
deriving Typeable
Email
email Text