@stackframe/stack 2.4.13 → 2.4.16
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/CHANGELOG.md +25 -0
- package/dist/components/credential-sign-in.js +45 -65
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/credential-sign-up.js +74 -98
- package/dist/components/credential-sign-up.js.map +1 -1
- package/dist/components/forgot-password.js +41 -38
- package/dist/components/forgot-password.js.map +1 -1
- package/dist/components/magic-link-sign-in.js +37 -41
- package/dist/components/magic-link-sign-in.js.map +1 -1
- package/dist/components/maybe-full-page.d.mts +9 -0
- package/dist/components/maybe-full-page.d.ts +9 -0
- package/dist/components/maybe-full-page.js +70 -0
- package/dist/components/maybe-full-page.js.map +1 -0
- package/dist/components/message-card.js +2 -2
- package/dist/components/message-card.js.map +1 -1
- package/dist/components/oauth-button.js +47 -53
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components/password-field.js +6 -8
- package/dist/components/password-field.js.map +1 -1
- package/dist/components/password-reset-inner.js +63 -58
- package/dist/components/password-reset-inner.js.map +1 -1
- package/dist/components/redirect-message-card.js +1 -2
- package/dist/components/redirect-message-card.js.map +1 -1
- package/dist/components/user-avatar.d.mts +1 -0
- package/dist/components/user-avatar.d.ts +1 -0
- package/dist/components/user-avatar.js +7 -5
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/user-button.js +14 -18
- package/dist/components/user-button.js.map +1 -1
- package/dist/components-core/button.d.mts +1 -0
- package/dist/components-core/button.d.ts +1 -0
- package/dist/components-core/button.js +31 -14
- package/dist/components-core/button.js.map +1 -1
- package/dist/components-core/card.js +3 -3
- package/dist/components-core/card.js.map +1 -1
- package/dist/components-core/input.js +10 -6
- package/dist/components-core/input.js.map +1 -1
- package/dist/components-core/label.js +2 -3
- package/dist/components-core/label.js.map +1 -1
- package/dist/components-core/tabs.js +9 -5
- package/dist/components-core/tabs.js.map +1 -1
- package/dist/components-page/account-settings.js +8 -8
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.js +5 -4
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/forgot-password.js +2 -2
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/oauth-callback.d.mts +3 -1
- package/dist/components-page/oauth-callback.d.ts +3 -1
- package/dist/components-page/oauth-callback.js +2 -2
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/password-reset.js.map +1 -1
- package/dist/components-page/sign-in.js +0 -2
- package/dist/components-page/sign-in.js.map +1 -1
- package/dist/components-page/sign-out.d.mts +4 -2
- package/dist/components-page/sign-out.d.ts +4 -2
- package/dist/components-page/sign-out.js +3 -3
- package/dist/components-page/sign-out.js.map +1 -1
- package/dist/components-page/stack-handler.d.mts +3 -1
- package/dist/components-page/stack-handler.d.ts +3 -1
- package/dist/components-page/stack-handler.js +17 -11
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components/credential-sign-in.js +45 -65
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/credential-sign-up.js +74 -98
- package/dist/esm/components/credential-sign-up.js.map +1 -1
- package/dist/esm/components/forgot-password.js +41 -38
- package/dist/esm/components/forgot-password.js.map +1 -1
- package/dist/esm/components/magic-link-sign-in.js +37 -41
- package/dist/esm/components/magic-link-sign-in.js.map +1 -1
- package/dist/esm/components/maybe-full-page.js +50 -0
- package/dist/esm/components/maybe-full-page.js.map +1 -0
- package/dist/esm/components/message-card.js +2 -2
- package/dist/esm/components/message-card.js.map +1 -1
- package/dist/esm/components/oauth-button.js +47 -53
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components/password-field.js +6 -8
- package/dist/esm/components/password-field.js.map +1 -1
- package/dist/esm/components/password-reset-inner.js +63 -58
- package/dist/esm/components/password-reset-inner.js.map +1 -1
- package/dist/esm/components/redirect-message-card.js +1 -2
- package/dist/esm/components/redirect-message-card.js.map +1 -1
- package/dist/esm/components/user-avatar.js +7 -5
- package/dist/esm/components/user-avatar.js.map +1 -1
- package/dist/esm/components/user-button.js +26 -19
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/components-core/button.js +33 -16
- package/dist/esm/components-core/button.js.map +1 -1
- package/dist/esm/components-core/card.js +3 -3
- package/dist/esm/components-core/card.js.map +1 -1
- package/dist/esm/components-core/input.js +11 -7
- package/dist/esm/components-core/input.js.map +1 -1
- package/dist/esm/components-core/label.js +2 -3
- package/dist/esm/components-core/label.js.map +1 -1
- package/dist/esm/components-core/tabs.js +10 -6
- package/dist/esm/components-core/tabs.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +8 -8
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.js +5 -4
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js +2 -2
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js +2 -2
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/password-reset.js.map +1 -1
- package/dist/esm/components-page/sign-in.js +0 -3
- package/dist/esm/components-page/sign-in.js.map +1 -1
- package/dist/esm/components-page/sign-out.js +3 -3
- package/dist/esm/components-page/sign-out.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +17 -11
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/lib/stack-app.js +18 -1
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/esm/utils/constants.js +10 -10
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/lib/hooks.d.mts +1 -0
- package/dist/lib/hooks.d.ts +1 -0
- package/dist/lib/stack-app.d.mts +6 -1
- package/dist/lib/stack-app.d.ts +6 -1
- package/dist/lib/stack-app.js +18 -1
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/stack-provider-client.d.mts +1 -0
- package/dist/providers/stack-provider-client.d.ts +1 -0
- package/dist/providers/stack-provider.d.mts +1 -0
- package/dist/providers/stack-provider.d.ts +1 -0
- package/dist/utils/constants.d.mts +26 -26
- package/dist/utils/constants.d.ts +26 -26
- package/dist/utils/constants.js +12 -12
- package/dist/utils/constants.js.map +1 -1
- package/package.json +10 -6
- package/dist/components/card-frame.d.mts +0 -9
- package/dist/components/card-frame.d.ts +0 -9
- package/dist/components/card-frame.js +0 -60
- package/dist/components/card-frame.js.map +0 -1
- package/dist/components-core/loading-indicator.d.mts +0 -11
- package/dist/components-core/loading-indicator.d.ts +0 -11
- package/dist/components-core/loading-indicator.js +0 -62
- package/dist/components-core/loading-indicator.js.map +0 -1
- package/dist/esm/components/card-frame.js +0 -40
- package/dist/esm/components/card-frame.js.map +0 -1
- package/dist/esm/components-core/loading-indicator.js +0 -31
- package/dist/esm/components-core/loading-indicator.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @stackframe/stack
|
|
2
2
|
|
|
3
|
+
## 2.4.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve setup flow
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @stackframe/stack-shared@2.4.13
|
|
10
|
+
- @stackframe/stack-sc@1.5.6
|
|
11
|
+
|
|
12
|
+
## 2.4.15
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Improved client styling, added login form, added spotify oauth
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @stackframe/stack-shared@2.4.12
|
|
19
|
+
|
|
20
|
+
## 2.4.14
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Added email editor
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @stackframe/stack-shared@2.4.11
|
|
27
|
+
|
|
3
28
|
## 2.4.13
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -35,79 +35,59 @@ __export(credential_sign_in_exports, {
|
|
|
35
35
|
default: () => CredentialSignIn
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(credential_sign_in_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_react_hook_form = require("react-hook-form");
|
|
39
|
+
var import_yup = require("@hookform/resolvers/yup");
|
|
40
|
+
var yup = __toESM(require("yup"));
|
|
39
41
|
var import_form_warning = __toESM(require("./form-warning"));
|
|
40
42
|
var import_password_field = __toESM(require("./password-field"));
|
|
41
|
-
var import_email = require("../utils/email");
|
|
42
43
|
var import__ = require("..");
|
|
43
44
|
var import_components_core = require("../components-core");
|
|
44
|
-
var
|
|
45
|
+
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
45
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var schema = yup.object().shape({
|
|
48
|
+
email: yup.string().email("Please enter a valid email").required("Please enter your email"),
|
|
49
|
+
password: yup.string().required("Please enter your password")
|
|
50
|
+
});
|
|
46
51
|
function CredentialSignIn() {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const [passwordError, setPasswordError] = (0, import_react.useState)("");
|
|
52
|
+
const { register, handleSubmit, setError, formState: { errors }, clearErrors } = (0, import_react_hook_form.useForm)({
|
|
53
|
+
resolver: (0, import_yup.yupResolver)(schema)
|
|
54
|
+
});
|
|
51
55
|
const app = (0, import__.useStackApp)();
|
|
52
|
-
const onSubmit = async () => {
|
|
53
|
-
|
|
54
|
-
setEmailError("Please enter your email");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (!(0, import_email.validateEmail)(email)) {
|
|
58
|
-
setEmailError("Please enter a valid email");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (!password) {
|
|
62
|
-
setPasswordError("Please enter your password");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
56
|
+
const onSubmit = async (data) => {
|
|
57
|
+
const { email, password } = data;
|
|
65
58
|
const error = await app.signInWithCredential({ email, password });
|
|
66
|
-
|
|
67
|
-
setPasswordError("Wrong email or password");
|
|
68
|
-
} else if (error) {
|
|
69
|
-
setEmailError(`An error occurred. ${error.message}`);
|
|
70
|
-
}
|
|
59
|
+
setError("email", { type: "manual", message: error?.message });
|
|
71
60
|
};
|
|
72
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
|
-
import_components_core.Button,
|
|
105
|
-
{
|
|
106
|
-
style: { marginTop: "1.5rem" },
|
|
107
|
-
onClick: onSubmit,
|
|
108
|
-
children: "Sign In"
|
|
109
|
-
}
|
|
110
|
-
)
|
|
111
|
-
] });
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
62
|
+
"form",
|
|
63
|
+
{
|
|
64
|
+
style: { display: "flex", flexDirection: "column", alignItems: "stretch" },
|
|
65
|
+
onSubmit: (e) => (0, import_promises.runAsynchronously)(handleSubmit(onSubmit)(e)),
|
|
66
|
+
noValidate: true,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "email", children: "Email" }),
|
|
69
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
import_components_core.Input,
|
|
71
|
+
{
|
|
72
|
+
id: "email",
|
|
73
|
+
type: "email",
|
|
74
|
+
...register("email")
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.email?.message?.toString() }),
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "password", style: { marginTop: "1rem" }, children: "Password" }),
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
import_password_field.default,
|
|
81
|
+
{
|
|
82
|
+
id: "password",
|
|
83
|
+
...register("password")
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.password?.message?.toString() }),
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Link, { href: app.urls.forgotPassword, size: "sm", style: { marginTop: "0.5rem" }, children: "Forgot password?" }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Button, { type: "submit", style: { marginTop: "1.5rem" }, children: "Sign In" })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
112
92
|
}
|
|
113
93
|
//# sourceMappingURL=credential-sign-in.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/credential-sign-in.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/components/credential-sign-in.tsx"],"sourcesContent":["'use client';\n\nimport { useForm } from \"react-hook-form\";\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport * as yup from \"yup\";\nimport FormWarningText from \"./form-warning\";\nimport PasswordField from \"./password-field\";\nimport { useStackApp } from \"..\";\nimport { Button, Input, Label, Link } from \"../components-core\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\n\nconst schema = yup.object().shape({\n email: yup.string().email('Please enter a valid email').required('Please enter your email'),\n password: yup.string().required('Please enter your password')\n});\n\nexport default function CredentialSignIn() {\n const { register, handleSubmit, setError, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n const { email, password } = data;\n\n const error = await app.signInWithCredential({ email, password });\n setError('email', { type: 'manual', message: error?.message });\n };\n\n return (\n <form \n style={{ display: 'flex', flexDirection: 'column', alignItems: 'stretch' }} \n onSubmit={e => runAsynchronously(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" style={{ marginTop: '1rem' }}>Password</Label>\n <PasswordField\n id=\"password\"\n {...register('password')}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n\n <Link href={app.urls.forgotPassword} size='sm' style={{ marginTop: '0.5rem' }}>\n Forgot password?\n </Link>\n\n <Button type=\"submit\" style={{ marginTop: '1.5rem' }}>\n Sign In\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAwB;AACxB,iBAA4B;AAC5B,UAAqB;AACrB,0BAA4B;AAC5B,4BAA0B;AAC1B,eAA4B;AAC5B,6BAA2C;AAC3C,sBAAkC;AAqB9B;AAnBJ,IAAM,SAAa,WAAO,EAAE,MAAM;AAAA,EAChC,OAAW,WAAO,EAAE,MAAM,4BAA4B,EAAE,SAAS,yBAAyB;AAAA,EAC1F,UAAc,WAAO,EAAE,SAAS,4BAA4B;AAC9D,CAAC;AAEc,SAAR,mBAAoC;AACzC,QAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,OAAO,GAAG,YAAY,QAAI,gCAAQ;AAAA,IACvF,cAAU,wBAAY,MAAM;AAAA,EAC9B,CAAC;AACD,QAAM,UAAM,sBAAY;AAExB,QAAM,WAAW,OAAO,SAAuC;AAC7D,UAAM,EAAE,OAAO,SAAS,IAAI;AAE5B,UAAM,QAAQ,MAAM,IAAI,qBAAqB,EAAE,OAAO,SAAS,CAAC;AAChE,aAAS,SAAS,EAAE,MAAM,UAAU,SAAS,OAAO,QAAQ,CAAC;AAAA,EAC/D;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,SAAS,QAAQ,eAAe,UAAU,YAAY,UAAU;AAAA,MACzE,UAAU,WAAK,mCAAkB,aAAa,QAAQ,EAAE,CAAC,CAAC;AAAA,MAC1D,YAAU;AAAA,MAEV;AAAA,oDAAC,gCAAM,SAAQ,SAAQ,mBAAK;AAAA,QAC5B;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACJ,GAAG,SAAS,OAAO;AAAA;AAAA,QACtB;AAAA,QACA,4CAAC,oBAAAA,SAAA,EAAgB,MAAM,OAAO,OAAO,SAAS,SAAS,GAAG;AAAA,QAE1D,4CAAC,gCAAM,SAAQ,YAAW,OAAO,EAAE,WAAW,OAAO,GAAG,sBAAQ;AAAA,QAChE;AAAA,UAAC,sBAAAC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACF,GAAG,SAAS,UAAU;AAAA;AAAA,QACzB;AAAA,QACA,4CAAC,oBAAAD,SAAA,EAAgB,MAAM,OAAO,UAAU,SAAS,SAAS,GAAG;AAAA,QAE7D,4CAAC,+BAAK,MAAM,IAAI,KAAK,gBAAgB,MAAK,MAAK,OAAO,EAAE,WAAW,SAAS,GAAG,8BAE/E;AAAA,QAEA,4CAAC,iCAAO,MAAK,UAAS,OAAO,EAAE,WAAW,SAAS,GAAG,qBAEtD;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["FormWarningText","PasswordField"]}
|
|
@@ -35,111 +35,87 @@ __export(credential_sign_up_exports, {
|
|
|
35
35
|
default: () => CredentialSignUp
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(credential_sign_up_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_react_hook_form = require("react-hook-form");
|
|
39
|
+
var import_yup = require("@hookform/resolvers/yup");
|
|
40
|
+
var yup = __toESM(require("yup"));
|
|
39
41
|
var import_password_field = __toESM(require("./password-field"));
|
|
40
42
|
var import_form_warning = __toESM(require("./form-warning"));
|
|
41
|
-
var import_email = require("../utils/email");
|
|
42
|
-
var import_password = require("@stackframe/stack-shared/dist/helpers/password");
|
|
43
43
|
var import__ = require("..");
|
|
44
44
|
var import_components_core = require("../components-core");
|
|
45
|
-
var
|
|
45
|
+
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
46
|
+
var import_password = require("@stackframe/stack-shared/dist/helpers/password");
|
|
46
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var schema = yup.object().shape({
|
|
49
|
+
email: yup.string().email("Please enter a valid email").required("Please enter your email"),
|
|
50
|
+
password: yup.string().required("Please enter your password").test({
|
|
51
|
+
name: "is-valid-password",
|
|
52
|
+
test: (value, ctx) => {
|
|
53
|
+
const error = (0, import_password.getPasswordError)(value);
|
|
54
|
+
if (error) {
|
|
55
|
+
return ctx.createError({ message: error.message });
|
|
56
|
+
} else {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
passwordRepeat: yup.string().nullable().oneOf([yup.ref("password"), null], "Passwords do not match").required("Please repeat your password")
|
|
62
|
+
});
|
|
47
63
|
function CredentialSignUp() {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const [passwordError, setPasswordError] = (0, import_react.useState)("");
|
|
52
|
-
const [passwordRepeat, setPasswordRepeat] = (0, import_react.useState)("");
|
|
53
|
-
const [passwordRepeatError, setPasswordRepeatError] = (0, import_react.useState)("");
|
|
64
|
+
const { register, handleSubmit, setError, formState: { errors }, clearErrors } = (0, import_react_hook_form.useForm)({
|
|
65
|
+
resolver: (0, import_yup.yupResolver)(schema)
|
|
66
|
+
});
|
|
54
67
|
const app = (0, import__.useStackApp)();
|
|
55
|
-
const onSubmit = async () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (!(0, import_email.validateEmail)(email)) {
|
|
61
|
-
setEmailError("Please enter a valid email");
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (!password) {
|
|
65
|
-
setPasswordError("Please enter your password");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (!passwordRepeat) {
|
|
69
|
-
setPasswordRepeatError("Please repeat your password");
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (password !== passwordRepeat) {
|
|
73
|
-
setPasswordRepeatError("Passwords do not match");
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const passwordError2 = (0, import_password.getPasswordError)(password);
|
|
77
|
-
if (passwordError2) {
|
|
78
|
-
setPasswordError(passwordError2.message);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
let error;
|
|
82
|
-
error = await app.signUpWithCredential({ email, password });
|
|
83
|
-
if (error instanceof import_stack_shared.KnownErrors.UserEmailAlreadyExists) {
|
|
84
|
-
setEmailError("User already exists");
|
|
85
|
-
} else if (error) {
|
|
86
|
-
setEmailError(`An error occurred. ${error.message}`);
|
|
87
|
-
}
|
|
68
|
+
const onSubmit = async (data) => {
|
|
69
|
+
const { email, password } = data;
|
|
70
|
+
const error = await app.signUpWithCredential({ email, password });
|
|
71
|
+
setError("email", { type: "manual", message: error?.message });
|
|
88
72
|
};
|
|
89
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
import_components_core.Button,
|
|
137
|
-
{
|
|
138
|
-
style: { marginTop: "1.5rem" },
|
|
139
|
-
onClick: onSubmit,
|
|
140
|
-
children: "Sign Up"
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
] });
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
74
|
+
"form",
|
|
75
|
+
{
|
|
76
|
+
style: { display: "flex", flexDirection: "column", alignItems: "stretch" },
|
|
77
|
+
onSubmit: (e) => (0, import_promises.runAsynchronously)(handleSubmit(onSubmit)(e)),
|
|
78
|
+
noValidate: true,
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "email", children: "Email" }),
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
import_components_core.Input,
|
|
83
|
+
{
|
|
84
|
+
id: "email",
|
|
85
|
+
type: "email",
|
|
86
|
+
...register("email")
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.email?.message?.toString() }),
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "password", style: { marginTop: "1rem" }, children: "Password" }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
import_password_field.default,
|
|
93
|
+
{
|
|
94
|
+
id: "password",
|
|
95
|
+
...register("password"),
|
|
96
|
+
onChange: (e) => {
|
|
97
|
+
clearErrors("password");
|
|
98
|
+
clearErrors("passwordRepeat");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.password?.message?.toString() }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "repeat-password", style: { marginTop: "1rem" }, children: "Repeat Password" }),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
import_password_field.default,
|
|
106
|
+
{
|
|
107
|
+
id: "repeat-password",
|
|
108
|
+
...register("passwordRepeat"),
|
|
109
|
+
onChange: (e) => {
|
|
110
|
+
clearErrors("password");
|
|
111
|
+
clearErrors("passwordRepeat");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.passwordRepeat?.message?.toString() }),
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Button, { type: "submit", style: { marginTop: "1.5rem" }, children: "Sign Up" })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
);
|
|
144
120
|
}
|
|
145
121
|
//# sourceMappingURL=credential-sign-up.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/credential-sign-up.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/components/credential-sign-up.tsx"],"sourcesContent":["'use client';\n\nimport { useForm } from \"react-hook-form\";\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport * as yup from \"yup\";\nimport PasswordField from \"./password-field\";\nimport FormWarningText from \"./form-warning\";\nimport { useStackApp } from \"..\";\nimport { Label, Input, Button } from \"../components-core\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { getPasswordError } from \"@stackframe/stack-shared/dist/helpers/password\";\n\nconst schema = yup.object().shape({\n email: yup.string().email('Please enter a valid email').required('Please enter your email'),\n password: yup.string().required('Please enter your password').test({\n name: 'is-valid-password',\n test: (value, ctx) => {\n const error = getPasswordError(value);\n if (error) {\n return ctx.createError({ message: error.message });\n } else {\n return true;\n }\n }\n }),\n passwordRepeat: yup.string().nullable().oneOf([yup.ref('password'), null], 'Passwords do not match').required('Please repeat your password')\n});\n\nexport default function CredentialSignUp() {\n const { register, handleSubmit, setError, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n const { email, password } = data;\n const error = await app.signUpWithCredential({ email, password });\n setError('email', { type: 'manual', message: error?.message });\n };\n\n return (\n <form \n style={{ display: 'flex', flexDirection: 'column', alignItems: 'stretch' }} \n onSubmit={e => runAsynchronously(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" style={{ marginTop: '1rem' }}>Password</Label>\n <PasswordField\n id=\"password\"\n {...register('password')}\n onChange={(e) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n }}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n \n <Label htmlFor=\"repeat-password\" style={{ marginTop: '1rem' }}>Repeat Password</Label>\n <PasswordField\n id=\"repeat-password\"\n {...register('passwordRepeat')}\n onChange={(e) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n }}\n />\n <FormWarningText text={errors.passwordRepeat?.message?.toString()} />\n\n <Button type=\"submit\" style={{ marginTop: '1.5rem' }}>\n Sign Up\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAwB;AACxB,iBAA4B;AAC5B,UAAqB;AACrB,4BAA0B;AAC1B,0BAA4B;AAC5B,eAA4B;AAC5B,6BAAqC;AACrC,sBAAkC;AAClC,sBAAiC;AA+B7B;AA7BJ,IAAM,SAAa,WAAO,EAAE,MAAM;AAAA,EAChC,OAAW,WAAO,EAAE,MAAM,4BAA4B,EAAE,SAAS,yBAAyB;AAAA,EAC1F,UAAc,WAAO,EAAE,SAAS,4BAA4B,EAAE,KAAK;AAAA,IACjE,MAAM;AAAA,IACN,MAAM,CAAC,OAAO,QAAQ;AACpB,YAAM,YAAQ,kCAAiB,KAAK;AACpC,UAAI,OAAO;AACT,eAAO,IAAI,YAAY,EAAE,SAAS,MAAM,QAAQ,CAAC;AAAA,MACnD,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,CAAC;AAAA,EACD,gBAAoB,WAAO,EAAE,SAAS,EAAE,MAAM,CAAK,QAAI,UAAU,GAAG,IAAI,GAAG,wBAAwB,EAAE,SAAS,6BAA6B;AAC7I,CAAC;AAEc,SAAR,mBAAoC;AACzC,QAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,OAAO,GAAG,YAAY,QAAI,gCAAQ;AAAA,IACvF,cAAU,wBAAY,MAAM;AAAA,EAC9B,CAAC;AACD,QAAM,UAAM,sBAAY;AAExB,QAAM,WAAW,OAAO,SAAuC;AAC7D,UAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,UAAM,QAAQ,MAAM,IAAI,qBAAqB,EAAE,OAAO,SAAS,CAAC;AAChE,aAAS,SAAS,EAAE,MAAM,UAAU,SAAS,OAAO,QAAQ,CAAC;AAAA,EAC/D;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,SAAS,QAAQ,eAAe,UAAU,YAAY,UAAU;AAAA,MACzE,UAAU,WAAK,mCAAkB,aAAa,QAAQ,EAAE,CAAC,CAAC;AAAA,MAC1D,YAAU;AAAA,MAEV;AAAA,oDAAC,gCAAM,SAAQ,SAAQ,mBAAK;AAAA,QAC5B;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACJ,GAAG,SAAS,OAAO;AAAA;AAAA,QACtB;AAAA,QACA,4CAAC,oBAAAA,SAAA,EAAgB,MAAM,OAAO,OAAO,SAAS,SAAS,GAAG;AAAA,QAE1D,4CAAC,gCAAM,SAAQ,YAAW,OAAO,EAAE,WAAW,OAAO,GAAG,sBAAQ;AAAA,QAChE;AAAA,UAAC,sBAAAC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACF,GAAG,SAAS,UAAU;AAAA,YACvB,UAAU,CAAC,MAAM;AACf,0BAAY,UAAU;AACtB,0BAAY,gBAAgB;AAAA,YAC9B;AAAA;AAAA,QACF;AAAA,QACA,4CAAC,oBAAAD,SAAA,EAAgB,MAAM,OAAO,UAAU,SAAS,SAAS,GAAG;AAAA,QAE7D,4CAAC,gCAAM,SAAQ,mBAAkB,OAAO,EAAE,WAAW,OAAO,GAAG,6BAAe;AAAA,QAC9E;AAAA,UAAC,sBAAAC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACF,GAAG,SAAS,gBAAgB;AAAA,YAC7B,UAAU,CAAC,MAAM;AACf,0BAAY,UAAU;AACtB,0BAAY,gBAAgB;AAAA,YAC9B;AAAA;AAAA,QACF;AAAA,QACA,4CAAC,oBAAAD,SAAA,EAAgB,MAAM,OAAO,gBAAgB,SAAS,SAAS,GAAG;AAAA,QAEnE,4CAAC,iCAAO,MAAK,UAAS,OAAO,EAAE,WAAW,SAAS,GAAG,qBAEtD;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["FormWarningText","PasswordField"]}
|
|
@@ -35,52 +35,55 @@ __export(forgot_password_exports, {
|
|
|
35
35
|
default: () => ForgotPassword
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(forgot_password_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_react_hook_form = require("react-hook-form");
|
|
39
|
+
var import_yup = require("@hookform/resolvers/yup");
|
|
40
|
+
var yup = __toESM(require("yup"));
|
|
39
41
|
var import_form_warning = __toESM(require("./form-warning"));
|
|
40
|
-
var import_email = require("../utils/email");
|
|
41
42
|
var import__ = require("..");
|
|
42
43
|
var import_components_core = require("../components-core");
|
|
44
|
+
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
43
45
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
+
var schema = yup.object().shape({
|
|
47
|
+
email: yup.string().email("Please enter a valid email").required("Please enter your email")
|
|
48
|
+
});
|
|
44
49
|
function ForgotPassword({ onSent }) {
|
|
45
|
-
const
|
|
46
|
-
|
|
50
|
+
const { register, handleSubmit, formState: { errors }, clearErrors } = (0, import_react_hook_form.useForm)({
|
|
51
|
+
resolver: (0, import_yup.yupResolver)(schema)
|
|
52
|
+
});
|
|
47
53
|
const stackApp = (0, import__.useStackApp)();
|
|
48
|
-
const onSubmit = async () => {
|
|
49
|
-
|
|
50
|
-
setEmailError("Please enter your email");
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (!(0, import_email.validateEmail)(email)) {
|
|
54
|
-
setEmailError("Please enter a valid email");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
54
|
+
const onSubmit = async (data) => {
|
|
55
|
+
const { email } = data;
|
|
57
56
|
await stackApp.sendForgotPasswordEmail(email);
|
|
58
57
|
onSent?.();
|
|
59
58
|
};
|
|
60
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
60
|
+
"form",
|
|
61
|
+
{
|
|
62
|
+
style: { display: "flex", flexDirection: "column", alignItems: "stretch" },
|
|
63
|
+
onSubmit: (e) => (0, import_promises.runAsynchronously)(handleSubmit(onSubmit)(e)),
|
|
64
|
+
noValidate: true,
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "email", children: "Your Email" }),
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
import_components_core.Input,
|
|
69
|
+
{
|
|
70
|
+
id: "email",
|
|
71
|
+
type: "email",
|
|
72
|
+
...register("email"),
|
|
73
|
+
onChange: () => clearErrors("email")
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.email?.message?.toString() }),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
|
+
import_components_core.Button,
|
|
79
|
+
{
|
|
80
|
+
type: "submit",
|
|
81
|
+
style: { marginTop: "1.5rem" },
|
|
82
|
+
children: "Send Email"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
85
88
|
}
|
|
86
89
|
//# sourceMappingURL=forgot-password.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/forgot-password.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/components/forgot-password.tsx"],"sourcesContent":["'use client';\n\nimport { useForm } from \"react-hook-form\";\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport * as yup from \"yup\";\nimport FormWarningText from \"./form-warning\";\nimport { useStackApp } from \"..\";\nimport { Button, Input, Label } from \"../components-core\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\n\nconst schema = yup.object().shape({\n email: yup.string().email('Please enter a valid email').required('Please enter your email')\n});\n\nexport default function ForgotPassword({ onSent }: { onSent?: () => void }) {\n const { register, handleSubmit, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const stackApp = useStackApp();\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n const { email } = data;\n await stackApp.sendForgotPasswordEmail(email);\n onSent?.();\n };\n\n return (\n <form\n style={{ display: 'flex', flexDirection: 'column', alignItems: 'stretch' }} \n onSubmit={e => runAsynchronously(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\">Your Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n {...register('email')}\n onChange={() => clearErrors('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Button\n type=\"submit\"\n style={{ marginTop: '1.5rem' }}\n >\n Send Email\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAwB;AACxB,iBAA4B;AAC5B,UAAqB;AACrB,0BAA4B;AAC5B,eAA4B;AAC5B,6BAAqC;AACrC,sBAAkC;AAmB9B;AAjBJ,IAAM,SAAa,WAAO,EAAE,MAAM;AAAA,EAChC,OAAW,WAAO,EAAE,MAAM,4BAA4B,EAAE,SAAS,yBAAyB;AAC5F,CAAC;AAEc,SAAR,eAAgC,EAAE,OAAO,GAA4B;AAC1E,QAAM,EAAE,UAAU,cAAc,WAAW,EAAE,OAAO,GAAG,YAAY,QAAI,gCAAQ;AAAA,IAC7E,cAAU,wBAAY,MAAM;AAAA,EAC9B,CAAC;AACD,QAAM,eAAW,sBAAY;AAE7B,QAAM,WAAW,OAAO,SAAuC;AAC7D,UAAM,EAAE,MAAM,IAAI;AAClB,UAAM,SAAS,wBAAwB,KAAK;AAC5C,aAAS;AAAA,EACX;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,SAAS,QAAQ,eAAe,UAAU,YAAY,UAAU;AAAA,MACzE,UAAU,WAAK,mCAAkB,aAAa,QAAQ,EAAE,CAAC,CAAC;AAAA,MAC1D,YAAU;AAAA,MAEV;AAAA,oDAAC,gCAAM,SAAQ,SAAQ,wBAAU;AAAA,QACjC;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACJ,GAAG,SAAS,OAAO;AAAA,YACpB,UAAU,MAAM,YAAY,OAAO;AAAA;AAAA,QACrC;AAAA,QACA,4CAAC,oBAAAA,SAAA,EAAgB,MAAM,OAAO,OAAO,SAAS,SAAS,GAAG;AAAA,QAE1D;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,OAAO,EAAE,WAAW,SAAS;AAAA,YAC9B;AAAA;AAAA,QAED;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["FormWarningText"]}
|
|
@@ -36,57 +36,53 @@ __export(magic_link_sign_in_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(magic_link_sign_in_exports);
|
|
38
38
|
var import_react = require("react");
|
|
39
|
+
var import_react_hook_form = require("react-hook-form");
|
|
40
|
+
var import_yup = require("@hookform/resolvers/yup");
|
|
41
|
+
var yup = __toESM(require("yup"));
|
|
39
42
|
var import_form_warning = __toESM(require("./form-warning"));
|
|
40
|
-
var import_email = require("../utils/email");
|
|
41
43
|
var import__ = require("..");
|
|
42
44
|
var import_components_core = require("../components-core");
|
|
45
|
+
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
43
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var schema = yup.object().shape({
|
|
48
|
+
email: yup.string().email("Please enter a valid email").required("Please enter your email")
|
|
49
|
+
});
|
|
44
50
|
function MagicLinkSignIn() {
|
|
45
|
-
const
|
|
51
|
+
const { register, handleSubmit, setError, formState: { errors }, clearErrors } = (0, import_react_hook_form.useForm)({
|
|
52
|
+
resolver: (0, import_yup.yupResolver)(schema)
|
|
53
|
+
});
|
|
46
54
|
const [sent, setSent] = (0, import_react.useState)(false);
|
|
47
|
-
const [error, setError] = (0, import_react.useState)("");
|
|
48
55
|
const app = (0, import__.useStackApp)();
|
|
49
|
-
const onSubmit = async () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!(0, import_email.validateEmail)(email)) {
|
|
55
|
-
setError("Please enter a valid email");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const error2 = await app.sendMagicLinkEmail(email);
|
|
59
|
-
if (error2) {
|
|
60
|
-
setError(error2.message);
|
|
56
|
+
const onSubmit = async (data) => {
|
|
57
|
+
const { email } = data;
|
|
58
|
+
const error = await app.sendMagicLinkEmail(email);
|
|
59
|
+
if (error) {
|
|
60
|
+
setError("email", { type: "manual", message: error.message });
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
setSent(true);
|
|
64
64
|
};
|
|
65
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
children: sent ? "Email sent" : "Send magic link"
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
] });
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
66
|
+
"form",
|
|
67
|
+
{
|
|
68
|
+
style: { display: "flex", flexDirection: "column", alignItems: "stretch" },
|
|
69
|
+
onSubmit: (e) => (0, import_promises.runAsynchronously)(handleSubmit(onSubmit)(e)),
|
|
70
|
+
noValidate: true,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Label, { htmlFor: "email", children: "Email" }),
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
import_components_core.Input,
|
|
75
|
+
{
|
|
76
|
+
id: "email",
|
|
77
|
+
type: "email",
|
|
78
|
+
...register("email"),
|
|
79
|
+
disabled: sent
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.default, { text: errors.email?.message?.toString() }),
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components_core.Button, { disabled: sent, style: { marginTop: "1.5rem" }, type: "submit", children: sent ? "Email sent" : "Send magic link" })
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
91
87
|
}
|
|
92
88
|
//# sourceMappingURL=magic-link-sign-in.js.map
|