diff --git a/Handler/Home.hs b/Handler/Home.hs index eddfbbd..c1ac281 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -1,8 +1,6 @@ module Handler.Home where import Import -import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, - withSmallInput) import Handler.Shared diff --git a/Handler/YourAccount.hs b/Handler/YourAccount.hs index 062d712..641a4b6 100644 --- a/Handler/YourAccount.hs +++ b/Handler/YourAccount.hs @@ -25,15 +25,19 @@ getYourAccountR = do postYourAccountR :: Handler Html postYourAccountR = do ((result, formWidget), formEnctype) <- runFormPost (yourAccountForm Nothing Nothing Nothing) + userId <- requireAuthId let accountData = case result of FormSuccess res -> Just res _ -> Nothing - Just (name, localId, mPassword, sshPubKey, avatarFile) = accountData - userId <- requireAuthId - updateUserAccount userId name localId mPassword sshPubKey avatarFile + case accountData of + Just (name, localId, mPassword, sshPubKey, avatarFile) -> do + updateUserAccount userId name localId mPassword sshPubKey avatarFile + Nothing -> do + setMessage $ toHtml ("Something went wrong, probably the password did not match" :: Text) defaultLayout $ do - setTitle "Your account" - $(widgetFile "your-account") + setTitle "Your account" + $(widgetFile "your-account") + yourAccountForm :: Maybe Text -> Maybe Text -> Maybe Text -> Form (Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe FileInfo) yourAccountForm maybeName maybeLocalId maybeSshPubKey = renderBootstrap3 BootstrapBasicForm $ (,,,,) @@ -133,7 +137,7 @@ passwordConfirmField = Field | otherwise -> return $ Left "Passwords don't match" [] -> return $ Right Nothing _ -> return $ Left "You must enter two values" - , fieldView = \idAttr nameAttr otherAttrs eResult isReq -> + , fieldView = \idAttr nameAttr otherAttrs _ _ -> [whamlet|
confirm: diff --git a/templates/homepage.hamlet b/templates/homepage.hamlet index 9d4bbc9..9e40ab8 100644 --- a/templates/homepage.hamlet +++ b/templates/homepage.hamlet @@ -9,7 +9,13 @@
  • free & open-source (AGPL), you can use it your own, in your company, at your university, etc. (git repo: git://gonito.net/gonito)
  • git-based (challenges and solutions are submitted only with git). - $maybe _ <- maybeUser + $maybe user <- maybeUser + $maybe _ <- userPassword $ entityVal user + $nothing +