diff --git a/Handler/Common.hs b/Handler/Common.hs index f104fd1..8de20ec 100644 --- a/Handler/Common.hs +++ b/Handler/Common.hs @@ -40,6 +40,7 @@ passwordConfirmField = Field updatePassword :: Key User -> Maybe Text -> Handler () updatePassword _ Nothing = return () +updatePassword _ (Just "") = return () updatePassword userId (Just password) = do encodedPassword <- liftIO $ makePassword (encodeUtf8 password) defaultStrength runDB $ update userId [UserPassword =. Just (decodeUtf8 encodedPassword)] diff --git a/Handler/YourAccount.hs b/Handler/YourAccount.hs index 5815db2..57ecd9e 100644 --- a/Handler/YourAccount.hs +++ b/Handler/YourAccount.hs @@ -44,8 +44,9 @@ postYourAccountR = do $(widgetFile "your-account") checkPassword :: Maybe Text -> Bool +checkPassword Nothing = True +checkPassword (Just "") = True checkPassword (Just passwd) = isPasswordAcceptable passwd -checkPassword Nothing = False yourAccountForm :: Maybe Text -> Maybe Text -> Maybe Text -> Form (Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe FileInfo) yourAccountForm maybeName maybeLocalId maybeSshPubKey = renderBootstrap3 BootstrapBasicForm $ (,,,,) @@ -74,7 +75,10 @@ updateUserAccount userId name maybeLocalId maybePassword maybeSshPubKey maybeAva updateJustName userId name updateAvatar userId maybeAvatarFile updateLocalIdAndPubKey userId maybeLocalId maybeSshPubKey - updatePassword userId maybePassword + case maybePassword of + Nothing -> return () + Just "" -> return () + Just p -> updatePassword userId (Just p) updateAvatar :: Key User -> Maybe FileInfo -> Handler () updateAvatar _ Nothing = return ()