password quality is checked in account settings as well
This commit is contained in:
parent
72c358ee62
commit
19b89f26ce
@ -49,8 +49,8 @@ minPasswordLength :: Int
|
||||
minPasswordLength = 10
|
||||
|
||||
isPasswordAcceptable :: Text -> Bool
|
||||
isPasswordAcceptable p = length p >= minPasswordLength
|
||||
isPasswordAcceptable p = length p >= minPasswordLength && (p /= "0123456789") && (p /= "1234567890")
|
||||
|
||||
tooWeakPasswordMessage :: Handler ()
|
||||
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.")
|
||||
|
@ -9,7 +9,7 @@ import Data.Conduit.Binary
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
|
||||
import Handler.Common (passwordConfirmField, updatePassword)
|
||||
import Handler.Common (passwordConfirmField, updatePassword, isPasswordAcceptable, tooWeakPasswordMessage)
|
||||
|
||||
getYourAccountR :: Handler Html
|
||||
getYourAccountR = do
|
||||
@ -32,13 +32,20 @@ postYourAccountR = do
|
||||
_ -> Nothing
|
||||
case accountData of
|
||||
Just (name, localId, mPassword, sshPubKey, avatarFile) -> do
|
||||
updateUserAccount userId name localId mPassword sshPubKey avatarFile
|
||||
if checkPassword mPassword
|
||||
then
|
||||
updateUserAccount userId name localId mPassword sshPubKey avatarFile
|
||||
else
|
||||
tooWeakPasswordMessage
|
||||
Nothing -> do
|
||||
setMessage $ toHtml ("Something went wrong, probably the password did not match" :: Text)
|
||||
defaultLayout $ do
|
||||
setTitle "Your account"
|
||||
$(widgetFile "your-account")
|
||||
|
||||
checkPassword :: Maybe Text -> Bool
|
||||
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 $ (,,,,)
|
||||
|
Loading…
Reference in New Issue
Block a user