Fixed sign in with an invite token when user is signed out
This commit is contained in:
@@ -14,6 +14,7 @@ import { AuthProviderButton } from './auth-provider-button';
|
||||
|
||||
export function OauthProviders(props: {
|
||||
inviteToken?: string;
|
||||
shouldCreateUser: boolean;
|
||||
enabledProviders: Provider[];
|
||||
|
||||
paths: {
|
||||
@@ -85,6 +86,7 @@ export function OauthProviders(props: {
|
||||
const credentials = {
|
||||
provider,
|
||||
options: {
|
||||
shouldCreateUser: props.shouldCreateUser,
|
||||
redirectTo,
|
||||
...scopesOpts,
|
||||
},
|
||||
|
||||
@@ -13,9 +13,12 @@ import { OauthProviders } from './oauth-providers';
|
||||
import { PasswordSignInContainer } from './password-sign-in-container';
|
||||
|
||||
export function SignInMethodsContainer(props: {
|
||||
inviteToken?: string;
|
||||
|
||||
paths: {
|
||||
callback: string;
|
||||
home: string;
|
||||
joinTeam: string;
|
||||
};
|
||||
|
||||
providers: {
|
||||
@@ -32,7 +35,17 @@ export function SignInMethodsContainer(props: {
|
||||
: '';
|
||||
|
||||
const onSignIn = () => {
|
||||
router.replace(nextPath);
|
||||
if (props.inviteToken) {
|
||||
const searchParams = new URLSearchParams({
|
||||
invite_token: props.inviteToken,
|
||||
});
|
||||
|
||||
const joinTeamPath = props.paths.joinTeam + '?' + searchParams.toString();
|
||||
|
||||
router.replace(joinTeamPath);
|
||||
} else {
|
||||
router.replace(nextPath);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -42,7 +55,10 @@ export function SignInMethodsContainer(props: {
|
||||
</If>
|
||||
|
||||
<If condition={props.providers.magicLink}>
|
||||
<MagicLinkAuthContainer redirectUrl={redirectUrl} />
|
||||
<MagicLinkAuthContainer
|
||||
inviteToken={props.inviteToken}
|
||||
redirectUrl={redirectUrl}
|
||||
/>
|
||||
</If>
|
||||
|
||||
<If condition={props.providers.oAuth.length}>
|
||||
@@ -50,6 +66,8 @@ export function SignInMethodsContainer(props: {
|
||||
|
||||
<OauthProviders
|
||||
enabledProviders={props.providers.oAuth}
|
||||
inviteToken={props.inviteToken}
|
||||
shouldCreateUser={false}
|
||||
paths={{
|
||||
callback: props.paths.callback,
|
||||
returnPath: props.paths.home,
|
||||
|
||||
@@ -51,6 +51,7 @@ export function SignUpMethodsContainer(props: {
|
||||
<OauthProviders
|
||||
enabledProviders={props.providers.oAuth}
|
||||
inviteToken={props.inviteToken}
|
||||
shouldCreateUser={true}
|
||||
paths={{
|
||||
callback: props.paths.callback,
|
||||
returnPath: props.paths.appHome,
|
||||
|
||||
Reference in New Issue
Block a user