Skip to content

Commit 193b345

Browse files
authored
fix(login) simpler oidc login screen (#1825)
## Done - fix(login) simpler oidc login screen When OIDC is configured, use a simpler login screen with fewer explanations: <img width="3840" height="1916" alt="image" src="https://github.com/user-attachments/assets/d4175bab-0433-41ba-94f8-e82705838e57" />
2 parents 24ef73e + 90800b2 commit 193b345

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

src/pages/login/Login.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { type FC } from "react";
22
import { Icon, Spinner, CustomLayout } from "@canonical/react-components";
3-
import { Navigate } from "react-router-dom";
3+
import { Link, Navigate } from "react-router-dom";
44
import { useAuth } from "context/auth";
55
import { ROOT_PATH } from "util/rootPath";
66
import AuthenticationOptions from "components/AuthenticationOptions";
7+
import { useSettings } from "context/useSettings";
8+
import { AUTH_METHOD } from "util/authentication";
79

810
const 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
</>

src/sass/_login.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
.p-login-method {
1212
max-width: unset;
1313
}
14+
15+
.auth-container {
16+
a,
17+
button {
18+
display: block;
19+
margin-bottom: $spv--small;
20+
width: 100%;
21+
}
22+
}
1423
}
1524
}
1625

0 commit comments

Comments
 (0)