Last active
July 14, 2023 13:56
-
-
Save ikovic/ecd65a4743d850d18ecf7adb2a6863b6 to your computer and use it in GitHub Desktop.
React SDK: <DynamicFlow>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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