11import { type FC } from "react" ;
22import { Icon , Spinner , CustomLayout } from "@canonical/react-components" ;
3- import { Navigate } from "react-router-dom" ;
3+ import { Link , Navigate } from "react-router-dom" ;
44import { useAuth } from "context/auth" ;
55import { ROOT_PATH } from "util/rootPath" ;
66import AuthenticationOptions from "components/AuthenticationOptions" ;
7+ import { useSettings } from "context/useSettings" ;
8+ import { AUTH_METHOD } from "util/authentication" ;
79
810const Login : FC = ( ) => {
911 const { isAuthenticated, isAuthLoading } = useAuth ( ) ;
12+ const { data : settings } = useSettings ( ) ;
13+ const hasOidc = settings ?. auth_methods ?. includes ( AUTH_METHOD . OIDC ) ;
1014
1115 if ( isAuthLoading ) {
1216 return < Spinner className = "u-loader" text = "Loading..." isMainComponent /> ;
@@ -20,9 +24,32 @@ const Login: FC = () => {
2024 < >
2125 < CustomLayout contentClassName = "login" >
2226 < div className = "empty-state login-page" >
23- < Icon name = "cluster-host" className = "lxd-icon" />
24- < h1 className = "p-heading--4 u-sv1" > Choose your login method</ h1 >
25- < AuthenticationOptions />
27+ { hasOidc && (
28+ < >
29+ < div className = "u-sv2" >
30+ < Icon name = "cluster-host" className = "lxd-icon" />
31+ </ div >
32+ < div className = "auth-container" >
33+ < a
34+ className = "p-button--positive has-icon"
35+ href = { `${ ROOT_PATH } /oidc/login` }
36+ >
37+ < Icon name = "security" light />
38+ < span > Login with SSO</ span >
39+ </ a >
40+ < Link to = { `${ ROOT_PATH } /ui/login/certificate-generate` } >
41+ < span > Set up TLS login</ span >
42+ </ Link >
43+ </ div >
44+ </ >
45+ ) }
46+ { ! hasOidc && (
47+ < >
48+ < Icon name = "cluster-host" className = "lxd-icon" />
49+ < h1 className = "p-heading--4 u-sv1" > Choose your login method</ h1 >
50+ < AuthenticationOptions />
51+ </ >
52+ ) }
2653 </ div >
2754 </ CustomLayout >
2855 </ >
0 commit comments