fix(campus-login): add i18n for ident placeholder

Fixes #417
This commit is contained in:
Gregor Kleen 2019-09-05 19:24:06 +02:00
parent b7496f9940
commit 692e533da0
2 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,4 @@
CampusIdentNote: Campus-Kennung bitte inkl. Domain-Teil (@campus.lmu.de) angeben.
CampusIdentPlaceholder: Vorname.Nachname@campus.lmu.de
CampusIdent: Campus-Kennung
CampusPassword: Passwort
CampusSubmit: Abschicken

View File

@ -33,7 +33,7 @@ data CampusLogin = CampusLogin
, campusPassword :: Text
} deriving (Generic, Typeable)
data CampusMessage = MsgCampusIdentNote
data CampusMessage = MsgCampusIdentPlaceholder
| MsgCampusIdent
| MsgCampusPassword
| MsgCampusSubmit
@ -117,10 +117,16 @@ campusUser' conf pool User{userIdent}
campusForm :: ( RenderMessage site FormMessage
, RenderMessage site CampusMessage
, Button site ButtonSubmit
) => AForm (HandlerT site IO) CampusLogin
campusForm = CampusLogin
<$> areq ciField (fslpI MsgCampusIdent "user.name@campus.lmu.de" & setTooltip MsgCampusIdentNote & addAttr "autofocus" "") Nothing
<*> areq passwordField (fslI MsgCampusPassword) Nothing
) => WForm (HandlerT site IO) (FormResult CampusLogin)
campusForm = do
MsgRenderer mr <- getMsgRenderer
ident <- wreq ciField (fslpI MsgCampusIdent (mr MsgCampusIdentPlaceholder) & addAttr "autofocus" "") Nothing
password <- wreq passwordField (fslI MsgCampusPassword) Nothing
return $ CampusLogin
<$> ident
<*> password
apLdap :: Text
apLdap = "LDAP"
@ -137,7 +143,7 @@ campusLogin conf@LdapConf{..} pool = AuthPlugin{..}
apName = apLdap
apDispatch :: Text -> [Text] -> HandlerT Auth (HandlerT site IO) TypedContent
apDispatch "POST" [] = do
((loginRes, _), _) <- lift . runFormPost $ renderAForm FormStandard campusForm
((loginRes, _), _) <- lift . runFormPost $ renderWForm FormStandard campusForm
case loginRes of
FormFailure errs -> do
forM_ errs $ addMessage Error . toHtml
@ -169,7 +175,7 @@ campusLogin conf@LdapConf{..} pool = AuthPlugin{..}
loginErrorMessageI LoginR Msg.AuthError
apDispatch _ _ = notFound
apLogin toMaster = do
(login, loginEnctype) <- handlerToWidget . generateFormPost $ renderAForm FormStandard campusForm
(login, loginEnctype) <- handlerToWidget . generateFormPost $ renderWForm FormStandard campusForm
let loginForm = wrapForm login FormSettings
{ formMethod = POST
, formAction = Just . SomeRoute . toMaster $ PluginR "LDAP" []