@proveanything/smartlinks-auth-ui 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -10797,7 +10797,8 @@ const PhoneAuthForm = ({ onSubmit, onBack, loading, error, collectName = false,
|
|
|
10797
10797
|
const handleSendCode = async (e) => {
|
|
10798
10798
|
e.preventDefault();
|
|
10799
10799
|
try {
|
|
10800
|
-
|
|
10800
|
+
const normalizedDisplayName = displayName.trim();
|
|
10801
|
+
await onSubmit(phoneNumber, undefined, collectName ? normalizedDisplayName || undefined : undefined);
|
|
10801
10802
|
// Only transition to code entry UI AFTER successful send
|
|
10802
10803
|
setCodeSent(true);
|
|
10803
10804
|
setResendCooldown(60); // 60 second cooldown
|
|
@@ -10872,7 +10873,8 @@ const MagicLinkForm = ({ onSubmit, onCancel, loading = false, error, collectName
|
|
|
10872
10873
|
const [displayName, setDisplayName] = React.useState('');
|
|
10873
10874
|
const handleSubmit = async (e) => {
|
|
10874
10875
|
e.preventDefault();
|
|
10875
|
-
|
|
10876
|
+
const normalizedDisplayName = displayName.trim();
|
|
10877
|
+
await onSubmit(email, collectName ? normalizedDisplayName || undefined : undefined);
|
|
10876
10878
|
};
|
|
10877
10879
|
return (jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "auth-form", children: [collectName && (jsxRuntime.jsxs("div", { className: "auth-form-group", children: [jsxRuntime.jsx("label", { htmlFor: "magic-link-name", className: "auth-label", children: "Name" }), jsxRuntime.jsx("input", { id: "magic-link-name", type: "text", value: displayName, onChange: (e) => setDisplayName(e.target.value), className: "auth-input", placeholder: "John Smith", disabled: loading, autoComplete: "name" })] })), jsxRuntime.jsxs("div", { className: "auth-form-group", children: [jsxRuntime.jsx("label", { htmlFor: "magic-link-email", className: "auth-label", children: "Email Address" }), jsxRuntime.jsx("input", { id: "magic-link-email", type: "email", value: email, onChange: (e) => setEmail(e.target.value), className: "auth-input", placeholder: "you@example.com", required: true, disabled: loading })] }), error && (jsxRuntime.jsx("div", { className: "auth-error-message", children: error })), jsxRuntime.jsx("button", { type: "submit", className: "auth-button auth-button-primary", disabled: loading || !email, children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "auth-spinner" }), "Sending..."] })) : ('Send Magic Link') }), jsxRuntime.jsx("button", { type: "button", onClick: onCancel, className: "auth-button auth-button-secondary", disabled: loading, children: "Cancel" })] }));
|
|
10878
10880
|
};
|
|
@@ -11313,10 +11315,14 @@ class AuthAPI {
|
|
|
11313
11315
|
try {
|
|
11314
11316
|
// Generate a random password since passwordless users won't use it
|
|
11315
11317
|
const randomPassword = crypto.randomUUID?.() || Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
|
|
11318
|
+
// Backend requires displayName to be a valid string
|
|
11319
|
+
// Fall back to email local part if no name provided
|
|
11320
|
+
const normalizedDisplayName = typeof data.displayName === 'string' ? data.displayName.trim() : '';
|
|
11321
|
+
const fallbackName = normalizedDisplayName || (data.email ? data.email.split('@')[0] : 'User');
|
|
11316
11322
|
await this.register({
|
|
11317
11323
|
email: data.email,
|
|
11318
11324
|
password: randomPassword,
|
|
11319
|
-
displayName:
|
|
11325
|
+
displayName: fallbackName,
|
|
11320
11326
|
});
|
|
11321
11327
|
this.log.log('ensureAccount: new account created for', data.email || data.phoneNumber);
|
|
11322
11328
|
}
|