fix: show correct authentication action for account required

When using account required auth for a given document
this change now shows the sign up or sign in button
depending on if an account actually exists within
Documenso.

This change should reduce friction and confusion when a
recipient has been invited to a document.
This commit is contained in:
Mythie
2024-06-20 10:59:07 +10:00
parent fbf4bd605f
commit cc667233c6
2 changed files with 14 additions and 4 deletions

View File

@ -11,9 +11,10 @@ import { useToast } from '@documenso/ui/primitives/use-toast';
export type SigningAuthPageViewProps = {
email: string;
emailHasAccount?: boolean;
};
export const SigningAuthPageView = ({ email }: SigningAuthPageViewProps) => {
export const SigningAuthPageView = ({ email, emailHasAccount }: SigningAuthPageViewProps) => {
const { toast } = useToast();
const [isSigningOut, setIsSigningOut] = useState(false);
@ -30,7 +31,9 @@ export const SigningAuthPageView = ({ email }: SigningAuthPageViewProps) => {
});
await signOut({
callbackUrl: `/signin?email=${encodeURIComponent(encryptedEmail)}`,
callbackUrl: emailHasAccount
? `/signin?email=${encodeURIComponent(encryptedEmail)}`
: `/signup?email=${encodeURIComponent(encryptedEmail)}`,
});
} catch {
toast({
@ -59,7 +62,7 @@ export const SigningAuthPageView = ({ email }: SigningAuthPageViewProps) => {
onClick={async () => handleChangeAccount(email)}
loading={isSigningOut}
>
Login
{emailHasAccount ? 'Login' : 'Sign up'}
</Button>
</div>
</div>