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