mirror of
https://github.com/documenso/documenso.git
synced 2026-09-29 16:24:30 +10:00
Selecting password auth failed with a generic "Unauthorized" for users who signed up via OAuth or passkey, with no way to set one. Detect the missing password and email the existing reset link from the signing dialog and security settings. Require a 2FA code and rate limit update-password.
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { isSigninEnabledForProvider } from '@documenso/lib/constants/auth';
|
|
import { Alert, AlertDescription, AlertTitle } from '@documenso/ui/primitives/alert';
|
|
import { Button } from '@documenso/ui/primitives/button';
|
|
import { DialogFooter } from '@documenso/ui/primitives/dialog';
|
|
import { Trans } from '@lingui/react/macro';
|
|
|
|
import { PasswordSetupRequest } from '~/components/forms/password-setup-request';
|
|
|
|
export type DocumentSigningAuthSetPasswordProps = {
|
|
onOpenChange: (value: boolean) => void;
|
|
};
|
|
|
|
/**
|
|
* Shown in place of the password reauth form when the signed in user has no
|
|
* password (e.g. they signed up via OAuth or a passkey).
|
|
*
|
|
* Password based action auth is meant to prove more than possession of a session,
|
|
* so rather than letting the session set a password inline we send the user the
|
|
* verified reset link and ask them to come back.
|
|
*/
|
|
export const DocumentSigningAuthSetPassword = ({ onOpenChange }: DocumentSigningAuthSetPasswordProps) => {
|
|
const isEmailPasswordSigninEnabled = isSigninEnabledForProvider('email');
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
{isEmailPasswordSigninEnabled ? (
|
|
<>
|
|
<Alert variant="neutral">
|
|
<AlertTitle>
|
|
<Trans>No password set</Trans>
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
<Trans>
|
|
Signing this field requires a password, but your account does not have one. We can email you a link to
|
|
set one. Once done, sign in again and return to this document to continue.
|
|
</Trans>
|
|
</AlertDescription>
|
|
</Alert>
|
|
|
|
<PasswordSetupRequest />
|
|
</>
|
|
) : (
|
|
<Alert variant="warning">
|
|
<AlertTitle>
|
|
<Trans>Password authentication unavailable</Trans>
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
<Trans>
|
|
Your account does not have a password and password sign in is disabled for this instance. Please contact
|
|
the document sender to use a different authentication method.
|
|
</Trans>
|
|
</AlertDescription>
|
|
</Alert>
|
|
)}
|
|
|
|
<DialogFooter>
|
|
<Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>
|
|
<Trans>Close</Trans>
|
|
</Button>
|
|
</DialogFooter>
|
|
</div>
|
|
);
|
|
};
|