Allow to skip login page if a single oidc provider is configured

This commit is contained in:
eikek
2022-07-08 17:09:56 +02:00
parent 275901267d
commit 3fc72cedac
12 changed files with 132 additions and 13 deletions

View File

@@ -36,6 +36,7 @@ type FormState
| AuthFailed AuthResult
| HttpError Http.Error
| FormInitial
| OidcLogoutPending
type AuthStep

View File

@@ -85,13 +85,23 @@ update loginData flags msg model =
session =
Maybe.withDefault "" loginData.session
in
-- A value of 2 indicates that TOTP is required
if loginData.openid == 2 then
-- A value of 2 indicates that TOTP is required
( { model | formState = FormInitial, authStep = StepOtp session, password = "" }
, Cmd.none
, Nothing
)
else if loginData.openid == 3 then
-- A valuo of 3 indicates a logout when a single
-- openid provider is configured with
-- oidcAutoredirect=true that doesn't have a logout
-- url configured
( { model | password = "", formState = OidcLogoutPending }
, Ports.removeAccount ()
, Just empty
)
else
( { model | password = "", formState = HttpError err }
, Ports.removeAccount ()

View File

@@ -95,7 +95,7 @@ openIdLinks texts flags =
div [ class "mt-3" ]
[ B.horizontalDivider
{ label = texts.or
, topCss = "w-2/3 mb-4 hidden md:inline-flex w-full"
, topCss = "w-full mb-4 hidden md:inline-flex w-full"
, labelCss = "px-4 bg-gray-200 bg-opacity-50"
, lineColor = "bg-gray-300 dark:bg-slate-600"
}
@@ -267,5 +267,10 @@ resultMessage texts model =
[ text (texts.httpError err)
]
OidcLogoutPending ->
div [ class ("my-2 max-w-xs " ++ S.warnMessage) ]
[ text texts.oidcLogoutPending
]
FormInitial ->
span [ class "hidden" ] []