Skip to content

Commit

Permalink
rework sso, sso directly with email
Browse files Browse the repository at this point in the history
  • Loading branch information
lovincyrus committed Nov 13, 2024
1 parent ec6c9ac commit 2b35a4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 86 deletions.
28 changes: 12 additions & 16 deletions web-auth/src/components/Auth.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import EmailPasswordForm from "./EmailPasswordForm.svelte";
import { getConnectionFromEmail } from "./utils";
import OrSeparator from "./OrSeparator.svelte";
import SSOForm from "./SSOForm.svelte";
import EmailSubmissionForm from "./EmailSubmissionForm.svelte";
import Disclaimer from "./Disclaimer.svelte";
import Spacer from "./Spacer.svelte";
Expand Down Expand Up @@ -75,28 +74,30 @@
webAuth = new auth0.WebAuth(authOptions);
}
function authorizeSSO(email: string, connectionName: string) {
webAuth.authorize({
connection: connectionName,
login_hint: email,
prompt: "login",
});
}
function processEmailSubmission(event) {
email = event.detail.email;
const connectionName = getConnectionFromEmail(email, connectionMapObj);
if (connectionName) {
step = AuthStep.SSO;
authorizeSSO(email, connectionName);
} else {
step = AuthStep.Login;
}
}
function getHeadingText(step: AuthStep): string {
if (isLegacy) {
return "Log in";
}
switch (step) {
case AuthStep.Base:
return "Log in or sign up";
case AuthStep.SSO:
return "Log in with SSO";
case AuthStep.Login:
return "Log in with email";
case AuthStep.SignUp:
Expand All @@ -107,19 +108,15 @@
return "";
}
}
$: headingText = getHeadingText(step);
function getSubheadingText(step: AuthStep, email: string): string {
switch (step) {
case AuthStep.SSO:
return `SAML SSO enabled workspace is associated with <span class="font-medium">${email}</span>`;
case AuthStep.Login:
return `Log in using <span class="font-medium">${email}</span>`;
default:
return "";
}
}
$: subheadingText = getSubheadingText(step, email);
function backToBaseStep() {
step = AuthStep.Base;
Expand All @@ -128,6 +125,9 @@
onMount(() => {
initConfig();
});
$: headingText = getHeadingText(step);
$: subheadingText = getSubheadingText(step, email);
</script>

<AuthContainer>
Expand Down Expand Up @@ -169,10 +169,6 @@
<EmailSubmissionForm on:submit={processEmailSubmission} />
{/if}

{#if step === AuthStep.SSO}
<SSOForm {email} {connectionMapObj} {webAuth} on:back={backToBaseStep} />
{/if}

{#if step === AuthStep.Login || step === AuthStep.SignUp}
<EmailPasswordForm
{step}
Expand Down
70 changes: 0 additions & 70 deletions web-auth/src/components/SSOForm.svelte

This file was deleted.

0 comments on commit 2b35a4c

Please sign in to comment.