Skip to content

Commit b54eb2b

Browse files
committed
stubbing out flow for sso login url
1 parent 3712520 commit b54eb2b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

components/dashboard/src/Login.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import exclamation from "./images/exclamation.svg";
2323
import { getURLHash } from "./utils";
2424
import ErrorMessage from "./components/ErrorMessage";
2525
import { Heading1, Heading2, Subheading } from "./components/typography/headings";
26+
import { SSOLoginForm } from "./login/SSOLoginForm";
2627

2728
function Item(props: { icon: string; iconSize?: string; text: string }) {
2829
const iconSize = props.iconSize || 28;
@@ -230,6 +231,9 @@ export function Login() {
230231
))
231232
)}
232233
</div>
234+
235+
<SSOLoginForm />
236+
233237
{errorMessage && <ErrorMessage imgSrc={exclamation} message={errorMessage} />}
234238
</div>
235239
</div>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License.AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { useMutation } from "@tanstack/react-query";
8+
import { FC, useCallback, useState } from "react";
9+
import { Button } from "../components/Button";
10+
import { TextInputField } from "../components/forms/TextInputField";
11+
12+
export const SSOLoginForm: FC = () => {
13+
const [orgSlug, setOrgSlug] = useState("");
14+
// TODO: remove this
15+
const [loginUrl, setLoginUrl] = useState("");
16+
17+
const exchangeSlug = useMutation({
18+
mutationFn: async ({ slug }: { slug: string }) => {
19+
// make api call to get provider id by slug
20+
// return provider id
21+
await new Promise((resolve) => setTimeout(resolve, 2000));
22+
23+
return { id: "sample-id" };
24+
},
25+
});
26+
27+
const handleSSOLogin = useCallback(
28+
async (e) => {
29+
e.preventDefault();
30+
31+
// make api call to get provider id by slug
32+
const { id } = await exchangeSlug.mutateAsync({ slug: orgSlug });
33+
34+
// create sso login url with provider id
35+
const loginUrl = `/oidc/start/?id=${id}`;
36+
setLoginUrl(loginUrl);
37+
38+
// openAuthorize window for sso w/ login url
39+
},
40+
[exchangeSlug, orgSlug],
41+
);
42+
43+
// TODO: Wrap with feature flag check
44+
return (
45+
<form onSubmit={handleSSOLogin}>
46+
<div className="mt-10 space-y-2">
47+
<TextInputField label="Organization Slug" value={orgSlug} onChange={setOrgSlug} />
48+
<Button className="w-full" type="secondary" disabled={!orgSlug} loading={exchangeSlug.isLoading}>
49+
Continue with SSO
50+
</Button>
51+
{loginUrl && <p>{loginUrl}</p>}
52+
</div>
53+
</form>
54+
);
55+
};

0 commit comments

Comments
 (0)