forked from filipg/gonito
add auxiliary function
This commit is contained in:
parent
846c2964cb
commit
b6336a65af
@ -54,3 +54,11 @@ isPasswordAcceptable p = length p >= minPasswordLength && (p /= "0123456789") &&
|
|||||||
tooWeakPasswordMessage :: Handler ()
|
tooWeakPasswordMessage :: Handler ()
|
||||||
tooWeakPasswordMessage =
|
tooWeakPasswordMessage =
|
||||||
setMessage $ toHtml ("Password is too weak!!! A password needs to have at least " ++ (show minPasswordLength) ++ " characters.")
|
setMessage $ toHtml ("Password is too weak!!! A password needs to have at least " ++ (show minPasswordLength) ++ " characters.")
|
||||||
|
|
||||||
|
checkIfCanEdit :: SubmissionId -> Handler Bool
|
||||||
|
checkIfCanEdit submissionId = do
|
||||||
|
submission <- runDB $ get404 submissionId
|
||||||
|
mUser <- maybeAuth
|
||||||
|
return $ case mUser of
|
||||||
|
Just (Entity userId user) -> userId == submissionSubmitter submission || userIsAdmin user
|
||||||
|
Nothing -> False
|
||||||
|
Loading…
Reference in New Issue
Block a user