* Updated to TailwindCSS v4 * Moved CSS module to its own CSS file because of lightingcss strict validation * Respect next parameter in middleware * Updated all packages. * Split CSSs for better organization. * Redesigned theme and auth pages * Improved pill and header design * Formatted files using Prettier * Better footer layout * Better auth layout * Bump version of the repository to 2.0.0
92 lines
2.3 KiB
TypeScript
92 lines
2.3 KiB
TypeScript
'use client';
|
|
|
|
import { useRouter, useSearchParams } from 'next/navigation';
|
|
|
|
import type { Provider } from '@supabase/supabase-js';
|
|
|
|
import { isBrowser } from '@kit/shared/utils';
|
|
import { If } from '@kit/ui/if';
|
|
import { Separator } from '@kit/ui/separator';
|
|
import { Trans } from '@kit/ui/trans';
|
|
|
|
import { MagicLinkAuthContainer } from './magic-link-auth-container';
|
|
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: {
|
|
password: boolean;
|
|
magicLink: boolean;
|
|
oAuth: Provider[];
|
|
};
|
|
}) {
|
|
const router = useRouter();
|
|
const nextPath = useSearchParams().get('next') ?? props.paths.home;
|
|
|
|
const redirectUrl = isBrowser()
|
|
? new URL(props.paths.callback, window?.location.origin).toString()
|
|
: '';
|
|
|
|
const onSignIn = () => {
|
|
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 (
|
|
<>
|
|
<If condition={props.providers.password}>
|
|
<PasswordSignInContainer onSignIn={onSignIn} />
|
|
</If>
|
|
|
|
<If condition={props.providers.magicLink}>
|
|
<MagicLinkAuthContainer
|
|
inviteToken={props.inviteToken}
|
|
redirectUrl={redirectUrl}
|
|
shouldCreateUser={false}
|
|
/>
|
|
</If>
|
|
|
|
<If condition={props.providers.oAuth.length}>
|
|
<div className="relative">
|
|
<div className="absolute inset-0 flex items-center">
|
|
<Separator />
|
|
</div>
|
|
|
|
<div className="relative flex justify-center text-xs uppercase">
|
|
<span className="bg-background text-muted-foreground px-2">
|
|
<Trans i18nKey="auth:orContinueWith" />
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<OauthProviders
|
|
enabledProviders={props.providers.oAuth}
|
|
inviteToken={props.inviteToken}
|
|
shouldCreateUser={false}
|
|
paths={{
|
|
callback: props.paths.callback,
|
|
returnPath: props.paths.home,
|
|
}}
|
|
/>
|
|
</If>
|
|
</>
|
|
);
|
|
}
|