handler cleanup
This commit is contained in:
parent
b4a4d6fd8f
commit
77aa2bf488
5 changed files with 14 additions and 14 deletions
|
@ -10,10 +10,10 @@ getActivateR token = do
|
|||
t <- runDB $ selectFirst [TokenToken ==. token] []
|
||||
case t of
|
||||
Nothing -> do
|
||||
setMessage $ [shamlet|<pre>Invalid Token!|]
|
||||
setMessage "Invalid Token!"
|
||||
redirect $ HomeR
|
||||
Just x -> do
|
||||
userId <- runDB $ insert $ tokenUser (entityVal x)
|
||||
liftIO $ createDirectory $ "data" </> (unpack $ extractKey userId)
|
||||
setMessage $ [shamlet|<pre>User activated|]
|
||||
setMessage $ "User activated"
|
||||
redirect $ HomeR
|
||||
|
|
|
@ -26,10 +26,10 @@ postLoginR = do
|
|||
case credentialsPasswd cred == userPassword (entityVal user) of
|
||||
True -> do
|
||||
setSession "userId" $ extractKey $ entityKey user
|
||||
setMessage $ [shamlet|<pre>Successfully logged in|]
|
||||
setMessage "Successfully logged in"
|
||||
redirect $ HomeR
|
||||
False -> do
|
||||
setMessage $ [shamlet|<pre>Login error|]
|
||||
setMessage $ "Login error"
|
||||
redirect $ LoginR
|
||||
Nothing -> do
|
||||
setMessage $ [shamlet|<pre>User does not exist|]
|
||||
|
@ -43,5 +43,5 @@ loginForm = renderDivs $ Credentials
|
|||
getLogoutR :: Handler Html
|
||||
getLogoutR = do
|
||||
deleteSession "userId"
|
||||
setMessage $ [shamlet|<pre>Succesfully logged out|]
|
||||
setMessage "Succesfully logged out"
|
||||
redirect $ HomeR
|
||||
|
|
|
@ -15,7 +15,7 @@ getNewAlbumR = do
|
|||
defaultLayout $ do
|
||||
$(widgetFile "newAlbum")
|
||||
Nothing -> do
|
||||
setMessage $ [shamlet|<pre>You need to be lgged in|]
|
||||
setMessage "You need to be lgged in"
|
||||
redirect $ LoginR
|
||||
|
||||
postNewAlbumR :: Handler Html
|
||||
|
@ -29,7 +29,7 @@ postNewAlbumR = do
|
|||
FormSuccess album -> do
|
||||
albumId <- runDB $ insert album
|
||||
liftIO $ createDirectory $ "data" </> (unpack $ extractKey userId) </> (unpack $ extractKey albumId)
|
||||
setMessage $ [shamlet|<pre>Album successfully created|]
|
||||
setMessage $ "Album successfully created"
|
||||
redirect $ ProfileR userId
|
||||
|
||||
albumForm :: UserId -> Form Album
|
||||
|
|
|
@ -30,13 +30,13 @@ postSignupR = do
|
|||
To complete your sgnup please activate your account by visiting the following link
|
||||
<a href="#{activateLink}">#{activateLink}
|
||||
|]
|
||||
setMessage $ [shamlet|<pre>User created|]
|
||||
setMessage "User created"
|
||||
redirect $ HomeR
|
||||
False -> do
|
||||
setMessage $ [shamlet|<pre>Username error|]
|
||||
setMessage "Username error"
|
||||
redirect $ SignupR
|
||||
_ -> do
|
||||
setMessage $ [shamlet|<pre>Please try again|]
|
||||
setMessage "Please try again"
|
||||
redirect $ SignupR
|
||||
|
||||
signupForm :: Form User
|
||||
|
|
|
@ -26,7 +26,7 @@ getUploadR = do
|
|||
defaultLayout $ do
|
||||
$(widgetFile "upload")
|
||||
Nothing -> do
|
||||
setMessage $ [shamlet|<pre>You need to be logged in|]
|
||||
setMessage "You need to be logged in"
|
||||
redirect $ LoginR
|
||||
|
||||
postUploadR :: Handler Html
|
||||
|
@ -48,13 +48,13 @@ postUploadR = do
|
|||
(tempMediumTags temp)
|
||||
(tempMediumAlbum temp)
|
||||
mId <- runDB $ I.insert medium
|
||||
setMessage $ [shamlet|<pre>Image succesfully uploaded|]
|
||||
setMessage "Image succesfully uploaded"
|
||||
redirect $ HomeR
|
||||
_ -> do
|
||||
setMessage $ [shamlet|<pre>There was an error uploading the file|]
|
||||
setMessage "There was an error uploading the file"
|
||||
redirect $ UploadR
|
||||
Nothing -> do
|
||||
setMessage $ [shamlet|<pre>You need to be logged in|]
|
||||
setMessage "You need to be logged in"
|
||||
redirect $ LoginR
|
||||
|
||||
writeOnDrive :: FileInfo -> Handler FilePath
|
||||
|
|
Loading…
Reference in a new issue