matebeamter/src/View/Auth.hs

77 lines
2.1 KiB
Haskell
Raw Normal View History

2019-09-08 00:37:50 +00:00
{-# LANGUAGE OverloadedStrings #-}
2019-10-04 07:04:23 +00:00
{-# LANGUAGE PackageImports #-}
2019-09-08 00:37:50 +00:00
module View.Auth where
2019-10-04 07:04:23 +00:00
import Servant.Links (linkURI)
2019-09-08 00:37:50 +00:00
import qualified Text.Blaze.Html5 as H
2019-10-04 07:04:23 +00:00
import qualified Text.Blaze.Html5.Attributes as HA
2019-09-08 00:37:50 +00:00
import qualified Data.Text as T
2019-09-08 15:27:38 +00:00
import Data.Text.I18n
2019-10-04 07:04:23 +00:00
import Data.String
-- imports from mateamt
import qualified "mateamt" Types.Auth as MT
2019-09-08 15:27:38 +00:00
-- internal imports
2019-09-08 00:37:50 +00:00
import Types
2019-10-04 07:04:23 +00:00
import API
2019-09-08 15:27:38 +00:00
import View.Scaffold
authPage
:: L10n
-> Locale
-> Maybe T.Text
2019-09-08 15:27:38 +00:00
-> AuthPage
authPage l10n locale mDestination = scaffold
2019-09-11 04:27:54 +00:00
l10n
locale
(initPage $
translate "Matebeamter" <>
" - " <>
translate "Authentication"
)
$ do
2019-10-04 07:04:23 +00:00
H.p $ H.form
H.! HA.method "post"
H.! HA.action ("/" <> (fromString $ show $ linkURI $
authPostLink mDestination))
2019-10-04 07:04:23 +00:00
H.! HA.enctype "application/x-www-form-urlencoded" $ do
H.div H.! HA.class_ "form-group required" $ do
H.label H.! HA.for "method" $ H.toHtml $
translate "Authentication Method"
H.select
H.! HA.id "method"
H.! HA.class_ "form-control"
H.! HA.name "authReturnMethod"
H.! HA.required ""
H.! HA.value (fromString $ show $ fromEnum MT.SecondaryPass) $ do
H.option H.!
HA.value (fromString $ show $ fromEnum MT.SecondaryPass) $
H.toHtml $ translate "Secondary Password"
H.option H.!
HA.value (fromString $ show $ fromEnum MT.PrimaryPass) $
H.toHtml $ translate "Primary Password"
H.div H.! HA.class_ "form-group required" $ do
H.label H.! HA.for "password" $ H.toHtml $
translate "Password"
H.input
H.! HA.id "password"
H.! HA.class_ "form_control"
H.! HA.name "authReturnPass"
H.! HA.type_ "password"
H.! HA.required ""
H.! HA.value ""
H.div H.! HA.class_ "form-group optional" $ do
H.button
H.! HA.class_ "btn btn-default"
H.! HA.type_ "submit"
$ H.toHtml $ translate "Submit"
2019-09-11 04:27:54 +00:00
where
translate = localize l10n locale . gettext