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

@ -12,6 +12,7 @@ module Data.Flags exposing
, getAccount
, getToken
, isAuthenticated
, oidcAutoRedirect
, withAccount
, withoutAccount
)
@ -22,6 +23,7 @@ import Api.Model.AuthResult exposing (AuthResult)
type alias OpenIdAuth =
{ provider : String
, name : String
, logoutUrl : Maybe String
}
@ -39,6 +41,7 @@ type alias Config =
, downloadAllMaxSize : Int
, openIdAuth : List OpenIdAuth
, addonsEnabled : Bool
, oidcAutoRedirect : Bool
}
@ -50,6 +53,20 @@ type alias Flags =
}
oidcAutoRedirect : Flags -> Maybe OpenIdAuth
oidcAutoRedirect flags =
if flags.config.oidcAutoRedirect then
case flags.config.openIdAuth of
first :: [] ->
Just first
_ ->
Nothing
else
Nothing
isAuthenticated : Flags -> Bool
isAuthenticated flags =
getAccount flags /= Nothing