Skip to content

Instantly share code, notes, and snippets.

@ikovic
Last active July 14, 2023 13:56
Show Gist options
  • Save ikovic/ecd65a4743d850d18ecf7adb2a6863b6 to your computer and use it in GitHub Desktop.
Save ikovic/ecd65a4743d850d18ecf7adb2a6863b6 to your computer and use it in GitHub Desktop.
React SDK: <DynamicFlow>
import { SlashIDProvider, DynamicFlow } from "@slashid/react"; // available from 1.6.4.
// first define a function that takes an email and returns a Factor
const getFactor = (email: string) => {
const domain = email.split("@")[1];
if (domain === "<REPLACE WITH THE DOMAIN>") {
return {
method: "oidc",
options: {
provider: "google",
client_id: "<REPLACE WITH THE CLIENT ID OF THE OIDC PROVIDER>",
},
} as Factor;
} else {
return { method: "email_link" } as Factor;
}
};
export const App = () => {
return (
<SlashIDProvider oid={"<YOUR ORGANIZATION ID"}>
<DynamicFlow className="<APPLY A CLASS NAME TO STYLE THE FLOW>>" getFactor={getFactor} />
</SlashIDProvider>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment