matebeamter/src/View/Auth.hs

80 lines
2.2 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
-> T.Text
2019-10-24 16:05:22 +00:00
-> Maybe T.Text
2019-09-08 15:27:38 +00:00
-> AuthPage
authPage l10n locale mDestination version mcookie = scaffold
2019-09-11 04:27:54 +00:00
l10n
locale
version
2019-10-24 16:05:22 +00:00
mcookie
2019-09-11 04:27:54 +00:00
(initPage $
translate "Matebeamter" <>
" - " <>
translate "Authentication"
)
2019-10-16 16:07:12 +00:00
$ H.p $ H.form
2019-10-04 07:04:23 +00:00
H.! HA.method "post"
2019-10-16 16:07:12 +00:00
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 ""
2019-10-16 16:07:12 +00:00
H.div H.! HA.class_ "form-group optional" $
2019-10-04 07:04:23 +00:00
H.button
H.! HA.class_ "btn btn-primary"
2019-10-04 07:04:23 +00:00
H.! HA.type_ "submit"
$ H.toHtml $ translate "Submit"
2019-09-11 04:27:54 +00:00
where
translate = localize l10n locale . gettext