@springmicro/auth 0.3.0 → 0.3.5

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.
Files changed (148) hide show
  1. package/.eslintrc.cjs +0 -0
  2. package/README.md +60 -60
  3. package/dist/{Index-c419311f-DolmVisI.js → Index-64ac63ff-mcEPPGzJ.js} +101 -102
  4. package/dist/{Index-652aeb8c-Cr1mbyJJ.js → Index-6c094240-D4xpr8fA.js} +70 -71
  5. package/dist/{Web3Auth-C5tucK1E.js → Web3Auth-DB9s-qbl.js} +12454 -12511
  6. package/dist/alphawallet-B7eovdf-.js +0 -0
  7. package/dist/apexwallet-ysP20G9D.js +0 -0
  8. package/dist/atoken-BBnNTzcz.js +0 -0
  9. package/dist/bifrostwallet-CNNBO92h.js +0 -0
  10. package/dist/binance-DvPgAzCw.js +0 -0
  11. package/dist/bitget-DZOUrwgy.js +0 -0
  12. package/dist/bitpie-C_uxmEzw.js +0 -0
  13. package/dist/bitski-DpzkHNkv.js +0 -0
  14. package/dist/blockwallet-BL69cqkA.js +0 -0
  15. package/dist/brave-DnRzMQYW.js +0 -0
  16. package/dist/ccip-c78d2f16-DLcRlwod.js +0 -0
  17. package/dist/coin98wallet-CkFdOvXt.js +0 -0
  18. package/dist/coinbase-CaGNx5if.js +0 -0
  19. package/dist/core-9rK8tWud.js +0 -0
  20. package/dist/defiwallet-0AsgJBSy.js +0 -0
  21. package/dist/detected-CX_JZaUk.js +0 -0
  22. package/dist/echooo-CmaetT_Z.js +0 -0
  23. package/dist/enkrypt-BibtwvK7.js +0 -0
  24. package/dist/exodus-BxzkDWWP.js +0 -0
  25. package/dist/fordefi-CvKyVwhI.js +0 -0
  26. package/dist/foxwallet-D7c_LDTf.js +0 -0
  27. package/dist/frame-CDfNmjUy.js +0 -0
  28. package/dist/frontier-DqKNSj2z.js +0 -0
  29. package/dist/hashMessage-Dw0KdqMZ.js +2101 -0
  30. package/dist/huobiwallet-CxSwqa5L.js +0 -0
  31. package/dist/hyperpay-nmHE3WqM.js +0 -0
  32. package/dist/icon-2Zqy7pqQ.js +0 -0
  33. package/dist/icon-CGWI1Ies.js +0 -0
  34. package/dist/icon-C_O4nprO.js +0 -0
  35. package/dist/icon-DbgmZCnU.js +0 -0
  36. package/dist/icon-Dbjb6jc5.js +20 -0
  37. package/dist/icon-cAd7RhSC.js +0 -0
  38. package/dist/imtoken-yENtOTS3.js +0 -0
  39. package/dist/index-021f6a62-Zz543EDB.js +0 -0
  40. package/dist/index-40a497ea-Bn2mC0r7.js +0 -0
  41. package/dist/{index-YKlm7xSx.js → index-C0yeApwY.js} +750 -751
  42. package/dist/{index-C4uVsW-I.js → index-CDaoza_m.js} +2 -2
  43. package/dist/index-CiwBcaZ0.js +384 -0
  44. package/dist/{index-DOUI-2vv.js → index-CroNOC7e.js} +27 -29
  45. package/dist/{index-Boi-WcMK.js → index-Df5ie3cE.js} +2 -2
  46. package/dist/{index-DzOmdGpF.js → index-F-gl3DJX.js} +8 -10
  47. package/dist/index-wNV8PBAh.js +11412 -0
  48. package/dist/index.d.ts +0 -0
  49. package/dist/index.js +1 -1
  50. package/dist/index.umd.cjs +327 -291
  51. package/dist/infinitywallet-C8J4FUYw.js +0 -0
  52. package/dist/kayros-AIrUK1za.js +0 -0
  53. package/dist/keplr-CyLTca9B.js +36 -0
  54. package/dist/lif3wallet-C5D6r8pg.js +0 -0
  55. package/dist/liquality-nbCtErVq.js +0 -0
  56. package/dist/mathwallet-CWkivCXo.js +0 -0
  57. package/dist/meetone-kKmvI8md.js +0 -0
  58. package/dist/metamask-BN7yiDV1.js +0 -0
  59. package/dist/mykey-CQZ6UcLH.js +0 -0
  60. package/dist/native-FDN9oNjc.js +15 -0
  61. package/dist/{number-UhidYs-H.js → number-ByqdQYDu.js} +1 -1
  62. package/dist/okxwallet-CJLVogh2.js +0 -0
  63. package/dist/oneInch-CciyZ4Pz.js +0 -0
  64. package/dist/onekey-Dal8kYjU.js +0 -0
  65. package/dist/opera-DnKg-TJU.js +0 -0
  66. package/dist/ownbit-BshJUVuW.js +0 -0
  67. package/dist/phantom-CJ8dIcov.js +0 -0
  68. package/dist/rabby-D4thTcd6.js +0 -0
  69. package/dist/rainbow-mXld6yWV.js +0 -0
  70. package/dist/roninwallet-ZyYrd-D1.js +0 -0
  71. package/dist/safeheron-Eg1Jb29V.js +0 -0
  72. package/dist/safepal-DVIKy94N.js +0 -0
  73. package/dist/sequence-BS2IbtDg.js +0 -0
  74. package/dist/stablewallet-jyB079Wb.js +0 -0
  75. package/dist/status-FrAvQjfn.js +0 -0
  76. package/dist/subwallet-DMvFqKyY.js +0 -0
  77. package/dist/talisman-Bp8zUXqB.js +0 -0
  78. package/dist/tallywallet-B4OS9nIr.js +0 -0
  79. package/dist/tokenary-C7jjcbQa.js +0 -0
  80. package/dist/tokenpocket-9ZRPmAFA.js +0 -0
  81. package/dist/tp-V2em5bdl.js +0 -0
  82. package/dist/transactionRequest-be6a8ea9-CUKWo5mx.js +0 -0
  83. package/dist/trust-SgHubMq7.js +20 -0
  84. package/dist/xdefi-COVIyGz4.js +0 -0
  85. package/dist/zeal-DxHbDqm0.js +0 -0
  86. package/dist/zerion-BfW0UElc.js +0 -0
  87. package/dist/zodiacpilot-CrId6F4w.js +0 -0
  88. package/index.html +0 -0
  89. package/package.json +2 -2
  90. package/src/auth/config.ts +91 -91
  91. package/src/components/SignUp.tsx +442 -442
  92. package/src/components/forms/AgreementModal.tsx +88 -88
  93. package/src/components/forms/CaptchaController.tsx +94 -94
  94. package/src/components/forms/CaptchaModal.jsx +171 -171
  95. package/src/components/forms/CaptchaWidget.jsx +146 -146
  96. package/src/components/forms/PasswordChecker.ts +88 -88
  97. package/src/components/forms/SendCodeInput.tsx +149 -149
  98. package/src/components/forms/SignUpFormItem.tsx +704 -704
  99. package/src/components/forms/util/application-api.ts +155 -155
  100. package/src/components/forms/util/auth-api.ts +198 -198
  101. package/src/components/forms/util/auth-util.tsx +346 -346
  102. package/src/components/forms/util/core.ts +493 -493
  103. package/src/components/forms/util/invitation-api.ts +132 -132
  104. package/src/components/forms/util/provider.tsx +603 -603
  105. package/src/components/forms/util/user-api.ts +303 -303
  106. package/src/components/provider/AdfsLoginButton.jsx +38 -38
  107. package/src/components/provider/AlipayLoginButton.jsx +38 -38
  108. package/src/components/provider/AppleLoginButton.jsx +38 -38
  109. package/src/components/provider/AzureADB2CLoginButton.jsx +38 -38
  110. package/src/components/provider/AzureADLoginButton.jsx +38 -38
  111. package/src/components/provider/BaiduLoginButton.jsx +38 -38
  112. package/src/components/provider/BilibiliLoginButton.jsx +37 -37
  113. package/src/components/provider/CasdoorLoginButton.jsx +38 -38
  114. package/src/components/provider/DingTalkLoginButton.jsx +37 -37
  115. package/src/components/provider/DouyinLoginButton.jsx +38 -38
  116. package/src/components/provider/FacebookLoginButton.jsx +37 -37
  117. package/src/components/provider/GitHubLoginButton.jsx +37 -37
  118. package/src/components/provider/GitLabLoginButton.jsx +38 -38
  119. package/src/components/provider/GiteeLoginButton.jsx +34 -34
  120. package/src/components/provider/GoogleLoginButton.jsx +68 -68
  121. package/src/components/provider/InfoflowLoginButton.jsx +38 -38
  122. package/src/components/provider/LarkLoginButton.jsx +38 -38
  123. package/src/components/provider/LinkedInLoginButton.jsx +37 -37
  124. package/src/components/provider/LoginButton.jsx +33 -33
  125. package/src/components/provider/OktaLoginButton.jsx +38 -38
  126. package/src/components/provider/Provider.jsx +3 -3
  127. package/src/components/provider/ProviderButton.jsx +327 -327
  128. package/src/components/provider/QqLoginButton.jsx +31 -31
  129. package/src/components/provider/SelfLoginButton.jsx +47 -47
  130. package/src/components/provider/SlackLoginButton.jsx +38 -38
  131. package/src/components/provider/SteamLoginButton.jsx +38 -38
  132. package/src/components/provider/WeComLoginButton.jsx +34 -34
  133. package/src/components/provider/Web3Auth.jsx +365 -365
  134. package/src/components/provider/WechatLoginButton.jsx +37 -37
  135. package/src/components/provider/WeiboLoginButton.jsx +34 -34
  136. package/src/components/util.tsx +173 -173
  137. package/src/i18n/en/signup.json +48 -48
  138. package/src/i18n/index.ts +17 -17
  139. package/src/index.tsx +8 -8
  140. package/src/vite-env.d.ts +0 -0
  141. package/tsconfig.json +0 -0
  142. package/tsconfig.node.json +0 -0
  143. package/vite.config.ts +33 -33
  144. package/dist/icon-duCa3gfT.js +0 -11
  145. package/dist/index-BtLU53lm.js +0 -6023
  146. package/dist/index-CLfsMiG4.js +0 -2021
  147. package/dist/index-DPq81SIn.js +0 -161
  148. package/dist/trust-gPypS1O7.js +0 -11
@@ -1,704 +1,704 @@
1
- // https://github.com/casdoor/casdoor/blob/master/web/src/auth/SignupPage.js
2
-
3
- import React, {
4
- type FormEvent,
5
- type InputHTMLAttributes,
6
- type ReactElement,
7
- } from "react";
8
- import type { Application } from "./util/provider";
9
- import type { SignUpFormState } from "../SignUp";
10
- import { useTranslation } from "react-i18next";
11
- import * as Setting from "./util/core";
12
- import * as AuthBackend from "./util/auth-api";
13
- import { SendCodeInput } from "./SendCodeInput";
14
- import * as ProviderButton from "../provider/ProviderButton";
15
- import * as PasswordChecker from "./PasswordChecker";
16
- import { AgreementModal } from "./AgreementModal";
17
- import { signIn } from "auth-astro/client";
18
- import { TFunction } from "i18next";
19
-
20
- type Rule = {
21
- required?: boolean;
22
- message?: string;
23
- whitespace?: boolean;
24
- pattern?: RegExp | string;
25
- validator?: (ev: any, value: string) => Promise<any>;
26
- validateTrigger?: string;
27
- };
28
-
29
- type FormItemProps = {
30
- label: string;
31
- name: string;
32
- inputEl?: ReactElement;
33
- rules: Array<Rule>;
34
- setFieldValue: (name: string, value: any) => void;
35
- };
36
-
37
- function FormItem({
38
- label,
39
- name,
40
- rules,
41
- inputEl,
42
- setFieldValue,
43
- onChange,
44
- ...rest
45
- }: FormItemProps & Partial<InputHTMLAttributes<HTMLInputElement>>) {
46
- // if (inputEl) {
47
- // inputEl.props.name = name;
48
- // }
49
- return (
50
- <label className="form-control w-full max-w-xs" htmlFor={name}>
51
- <div className="label">
52
- <span className="label-text">{label}</span>
53
- </div>
54
- {inputEl ? (
55
- inputEl
56
- ) : (
57
- <input
58
- type="text"
59
- {...rest}
60
- name={name}
61
- className="input input-bordered w-full max-w-xs"
62
- onChange={(e) => {
63
- setFieldValue(name, e.target.value);
64
- onChange?.(e);
65
- }}
66
- />
67
- )}
68
-
69
- <div className="label flex-col">
70
- {rules?.map((rule, i) => (
71
- <span className="label-text-alt" key={name + i}>
72
- {rule.message}
73
- </span>
74
- ))}
75
- </div>
76
- </label>
77
- );
78
- }
79
-
80
- const getValues = (state: SignUpFormState, application: Application) => {
81
- // example state
82
- // const s = {
83
- // applicationName: null,
84
- // email: "runalldayandnight@gmail.com",
85
- // phone: "",
86
- // emailOrPhoneMode: "",
87
- // countryCode: "",
88
- // emailCode: "985028",
89
- // phoneCode: "",
90
- // validEmail: true,
91
- // validPhone: false,
92
- // region: "",
93
- // isTermsOfUseVisible: false,
94
- // termsOfUseContent: "",
95
- // agreement: true,
96
- // password: "password",
97
- // confirm: "password",
98
- // username: "db",
99
- // };
100
- delete state.applicationName;
101
- delete state.emailOrPhoneMode;
102
- delete state.isTermsOfUseVisible;
103
- return {
104
- application: application.name,
105
- organization: application.organization,
106
- plan: null,
107
- pricing: null,
108
- ...state,
109
- };
110
- };
111
-
112
- // values is formData json
113
- const onSubmit = (
114
- e: FormEvent<HTMLFormElement>,
115
- state: SignUpFormState,
116
- application: Application
117
- ) => {
118
- e.preventDefault();
119
-
120
- const values = getValues(state, application);
121
- console.log(values);
122
- AuthBackend.signup(values).then((res) => {
123
- if (res.status === "ok") {
124
- // the user's id will be returned by `signup()`, if user signup by phone, the `username` in `values` is undefined.
125
- values.username = res.data.split("/")[1];
126
- // has prompt page is for like oauth with Google
127
- if (application && Setting.hasPromptPage(application)) {
128
- // TODO
129
- AuthBackend.getAccount("").then((res) => {
130
- let account = null;
131
- if (res.status === "ok") {
132
- account = res.data;
133
- account.organization = res.data2;
134
- console.log("account", account);
135
- // TODO log in
136
- // Webhooks
137
- // this.onUpdateAccount(account);
138
- //Setting.goToLinkSoft(this, this.getResultPath(application, values));
139
- alert("redirect");
140
- } else {
141
- Setting.showMessage("error", `Failed to sign in: ${res.msg}`);
142
- }
143
- });
144
- } else {
145
- alert("redirect");
146
- signIn();
147
- // Setting.goToLinkSoft(this, this.getResultPath(application, values));
148
- }
149
- } else {
150
- Setting.showMessage("error", res.msg);
151
- }
152
- });
153
- };
154
-
155
- export function renderFormItem(
156
- application: Application,
157
- signupItem: any,
158
- state: SignUpFormState,
159
- setState: React.Dispatch<React.SetStateAction<SignUpFormState>>,
160
- t: TFunction<"translation", undefined>
161
- ) {
162
- if (!signupItem.visible) {
163
- return null;
164
- }
165
-
166
- const setFieldValue = (name: string, value: any) => {
167
- //@ts-ignore
168
- state[name] = value;
169
- setState(state);
170
- };
171
- const required = signupItem.required;
172
-
173
- if (signupItem.name === "Username") {
174
- return (
175
- <FormItem
176
- name="username"
177
- className="signup-username"
178
- label={signupItem.label ? signupItem.label : t("signup.username")}
179
- rules={[
180
- {
181
- required: required,
182
- message: t("forget.username"),
183
- whitespace: true,
184
- },
185
- ]}
186
- placeholder={signupItem.placeholder}
187
- disabled={
188
- state.invitation !== undefined && state.invitation.username !== ""
189
- }
190
- setFieldValue={setFieldValue}
191
- />
192
- );
193
- } else if (signupItem.name === "Display name") {
194
- if (signupItem.rule === "First, last" && Setting.getLanguage() !== "zh") {
195
- return (
196
- <React.Fragment>
197
- <FormItem
198
- name="firstName"
199
- className="signup-first-name"
200
- label={signupItem.label ? signupItem.label : t("general.firstName")}
201
- rules={[
202
- {
203
- required: required,
204
- message: t("forget.firstName"),
205
- whitespace: true,
206
- },
207
- ]}
208
- placeholder={signupItem.placeholder}
209
- setFieldValue={setFieldValue}
210
- />
211
-
212
- <FormItem
213
- name="lastName"
214
- className="signup-last-name"
215
- label={signupItem.label ? signupItem.label : t("general.lastName")}
216
- rules={[
217
- {
218
- required: required,
219
- message: t("forget.lastName"),
220
- whitespace: true,
221
- },
222
- ]}
223
- placeholder={signupItem.placeholder}
224
- setFieldValue={setFieldValue}
225
- />
226
- </React.Fragment>
227
- );
228
- } else {
229
- return (
230
- <FormItem
231
- name="name"
232
- className="signup-name"
233
- label={
234
- signupItem.label
235
- ? signupItem.label
236
- : signupItem.rule === "Real name" ||
237
- signupItem.rule === "First, last"
238
- ? t("general.realName")
239
- : t("general.displayName")
240
- }
241
- rules={[
242
- {
243
- required: required,
244
- message:
245
- signupItem.rule === "Real name" ||
246
- signupItem.rule === "First, last"
247
- ? t("forget.realName")
248
- : t("forget.displayName"),
249
- whitespace: true,
250
- },
251
- ]}
252
- placeholder={signupItem.placeholder}
253
- setFieldValue={setFieldValue}
254
- />
255
- );
256
- }
257
- } else if (signupItem.name === "Affiliation") {
258
- return (
259
- <FormItem
260
- name="affiliation"
261
- className="signup-affiliation"
262
- label={signupItem.label ? signupItem.label : t("user.affiliation")}
263
- rules={[
264
- {
265
- required: required,
266
- message: t("forget.affiliation"),
267
- whitespace: true,
268
- },
269
- ]}
270
- placeholder={signupItem.placeholder}
271
- setFieldValue={setFieldValue}
272
- />
273
- );
274
- } else if (signupItem.name === "ID card") {
275
- return (
276
- <FormItem
277
- name="idCard"
278
- className="signup-idcard"
279
- label={signupItem.label ? signupItem.label : t("user.idCard")}
280
- rules={[
281
- {
282
- required: required,
283
- message: t("forget.idCard"),
284
- whitespace: true,
285
- },
286
- {
287
- required: required,
288
- pattern: new RegExp(
289
- /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/,
290
- "g"
291
- ),
292
- message: t("format.idCard"),
293
- },
294
- ]}
295
- placeholder={signupItem.placeholder}
296
- setFieldValue={setFieldValue}
297
- />
298
- );
299
- } else if (
300
- signupItem.name === "Email" ||
301
- signupItem.name === "Phone" ||
302
- signupItem.name === "Email or Phone" ||
303
- signupItem.name === "Phone or Email"
304
- ) {
305
- const renderEmailItem = () => {
306
- return (
307
- <React.Fragment>
308
- <FormItem
309
- name="email"
310
- // className="signup-email"
311
- label={signupItem.label ? signupItem.label : t("general.email")}
312
- rules={[
313
- {
314
- required: required,
315
- message: t("forget.email"),
316
- },
317
- ]}
318
- placeholder={signupItem.placeholder}
319
- disabled={
320
- state.invitation !== undefined && state.invitation.email !== ""
321
- }
322
- onChange={(e: any) => {
323
- const email = e.target.value;
324
- console.log("email", email, Setting.isValidEmail(email));
325
- if (email !== "" && !Setting.isValidEmail(email)) {
326
- setState({ ...state, email, validEmail: false });
327
- } else {
328
- setState({ ...state, email, validEmail: true });
329
- }
330
- }}
331
- setFieldValue={setFieldValue}
332
- />
333
-
334
- {signupItem.rule !== "No verification" && (
335
- <FormItem
336
- name="emailCode"
337
- className="signup-email-code"
338
- label={signupItem.label ? signupItem.label : t("code.email")}
339
- rules={[
340
- {
341
- required: required,
342
- message: t("forget.code"),
343
- },
344
- ]}
345
- inputEl={
346
- <SendCodeInput
347
- // className="signup-email-code-input"
348
- disabled={!state.validEmail}
349
- method={"signup"}
350
- onButtonClickArgs={[state.email, "email", application.name]}
351
- application={application}
352
- countryCode="US"
353
- onChange={(value: string) =>
354
- setState({ ...state, emailCode: value })
355
- }
356
- />
357
- }
358
- setFieldValue={setFieldValue}
359
- />
360
- )}
361
- </React.Fragment>
362
- );
363
- };
364
-
365
- const renderPhoneItem = () => {
366
- return <></>;
367
- // return (
368
- // <React.Fragment>
369
- // <FormItem
370
- // className="signup-phone"
371
- // label={
372
- // signupItem.label ? signupItem.label : t("general:Phone")
373
- // }
374
- // required={required}
375
- // >
376
- // <Input.Group compact>
377
- // <FormItem
378
- // name="countryCode"
379
- // noStyle
380
- // rules={[
381
- // {
382
- // required: required,
383
- // message: t(
384
- // "signup:Please select your country code!"
385
- // ),
386
- // },
387
- // ]}
388
- // >
389
- // <CountryCodeSelect
390
- // style={{ width: "35%" }}
391
- // countryCodes={
392
- // this.getApplicationObj().organizationObj.countryCodes
393
- // }
394
- // />
395
-
396
- // <FormItem
397
- // name="phone"
398
- // dependencies={["countryCode"]}
399
- // noStyle
400
- // rules={[
401
- // {
402
- // required: required,
403
- // message: t(
404
- // "signup:Please input your phone number!"
405
- // ),
406
- // },
407
- // ({ getFieldValue }) => ({
408
- // validator: (_, value) => {
409
- // if (!required && !value) {
410
- // return Promise.resolve();
411
- // }
412
-
413
- // if (
414
- // value &&
415
- // !Setting.isValidPhone(
416
- // value,
417
- // getFieldValue("countryCode")
418
- // )
419
- // ) {
420
- // setState({ ...state, validPhone: false });
421
- // return Promise.reject(
422
- // t("signup:The input is not valid Phone!")
423
- // );
424
- // }
425
-
426
- // setState({ ...state, validPhone: true });
427
- // return Promise.resolve();
428
- // },
429
- // }),
430
- // ]}
431
- // >
432
- // <Input
433
- // className="signup-phone-input"
434
- // placeholder={signupItem.placeholder}
435
- // style={{ width: "65%" }}
436
- // disabled={
437
- // state.invitation !== undefined &&
438
- // state.invitation.phone !== ""
439
- // }
440
- // onChange={(e) =>
441
- // setState({ ...state, phone: e.target.value })
442
- // }
443
- // />
444
-
445
- // </Input.Group>
446
-
447
- // {signupItem.rule !== "No verification" && (
448
- // <FormItem
449
- // name="phoneCode"
450
- // className="phone-code"
451
- // label={
452
- // signupItem.label
453
- // ? signupItem.label
454
- // : t("code:Phone code")
455
- // }
456
- // rules={[
457
- // {
458
- // required: required,
459
- // message: t(
460
- // "code:Please input your phone verification code!"
461
- // ),
462
- // },
463
- // ]}
464
- // >
465
- // <SendCodeInput
466
- // className="signup-phone-code-input"
467
- // disabled={!state.validPhone}
468
- // method={"signup"}
469
- // onButtonClickArgs={[
470
- // state.phone,
471
- // "phone",
472
- // Setting.getApplicationName(application),
473
- // ]}
474
- // application={application}
475
- // countryCode={this.form.current?.getFieldValue("countryCode")}
476
- // />
477
-
478
- // )}
479
- // </React.Fragment>
480
- // );
481
- };
482
-
483
- if (signupItem.name === "Email") {
484
- return renderEmailItem();
485
- } else if (signupItem.name === "Phone") {
486
- return renderPhoneItem();
487
- } else if (
488
- signupItem.name === "Email or Phone" ||
489
- signupItem.name === "Phone or Email"
490
- ) {
491
- let emailOrPhoneMode = state.emailOrPhoneMode;
492
- if (emailOrPhoneMode === "") {
493
- emailOrPhoneMode =
494
- signupItem.name === "Email or Phone" ? "Email" : "Phone";
495
- }
496
-
497
- return (
498
- <React.Fragment>
499
- <div style={{ marginTop: "30px", marginBottom: "20px" }}>
500
- {/* <Radio.Group
501
- style={{ width: "400px" }}
502
- buttonStyle="solid"
503
- onChange={(e) => {
504
- setState({ ...state, emailOrPhoneMode: e.target.value });
505
- }}
506
- value={emailOrPhoneMode}
507
- >
508
- {signupItem.name === "Email or Phone" ? (
509
- <React.Fragment>
510
- <Radio.Button value={"Email"}>
511
- {t("general:Email")}
512
- </Radio.Button>
513
- <Radio.Button value={"Phone"}>
514
- {t("general:Phone")}
515
- </Radio.Button>
516
- </React.Fragment>
517
- ) : (
518
- <React.Fragment>
519
- <Radio.Button value={"Phone"}>
520
- {t("general:Phone")}
521
- </Radio.Button>
522
- <Radio.Button value={"Email"}>
523
- {t("general:Email")}
524
- </Radio.Button>
525
- </React.Fragment>
526
- )}
527
- </Radio.Group> */}
528
- </div>
529
- {emailOrPhoneMode === "Email" ? renderEmailItem() : renderPhoneItem()}
530
- </React.Fragment>
531
- );
532
- } else {
533
- return null;
534
- }
535
- } else if (signupItem.name === "Password") {
536
- return (
537
- <FormItem
538
- name="password"
539
- className="signup-password"
540
- label={signupItem.label ? signupItem.label : t("general.password")}
541
- rules={[
542
- {
543
- required: required,
544
- validateTrigger: "onChange",
545
- validator: (rule, value) => {
546
- const errorMsg = PasswordChecker.checkPasswordComplexity(
547
- value,
548
- application.organizationObj.passwordOptions
549
- );
550
- if (errorMsg === "") {
551
- return Promise.resolve();
552
- } else {
553
- return Promise.reject(errorMsg);
554
- }
555
- },
556
- },
557
- ]}
558
- setFieldValue={setFieldValue}
559
- // hasFeedback
560
- type="password"
561
- placeholder={signupItem.placeholder}
562
- />
563
- );
564
- } else if (signupItem.name === "Confirm password") {
565
- return (
566
- <FormItem
567
- name="confirm"
568
- className="signup-confirm"
569
- label={signupItem.label ? signupItem.label : t("signup.confirm")}
570
- // dependencies={["password"]}
571
- // hasFeedback
572
- rules={[
573
- {
574
- required: required,
575
- message: t("forget.confirm"),
576
- },
577
- // ({ getFieldValue }) => ({
578
- // validator(rule, value) {
579
- // if (!value || getFieldValue("password") === value) {
580
- // return Promise.resolve();
581
- // }
582
-
583
- // return Promise.reject(
584
- // t(
585
- // "signup:Your confirmed password is inconsistent with the password!"
586
- // )
587
- // );
588
- // },
589
- // }),
590
- ]}
591
- type="password"
592
- placeholder={signupItem.placeholder}
593
- setFieldValue={setFieldValue}
594
- />
595
- );
596
- } else if (signupItem.name === "Invitation code") {
597
- return (
598
- <FormItem
599
- name="invitationCode"
600
- className="signup-invitation-code"
601
- label={
602
- signupItem.label ? signupItem.label : t("application.invitationCode")
603
- }
604
- rules={[
605
- {
606
- required: required,
607
- message: t("forget.invitationCode"),
608
- },
609
- ]}
610
- placeholder={signupItem.placeholder}
611
- disabled={state.invitation !== undefined && state.invitation !== ""}
612
- setFieldValue={setFieldValue}
613
- />
614
- );
615
- } else if (signupItem.name === "Agreement") {
616
- return (
617
- <AgreementModal
618
- state={state}
619
- setState={setState}
620
- application={application}
621
- />
622
- );
623
- // return AgreementModal.renderAgreementFormItem(
624
- // application,
625
- // required,
626
- // tailFormItemLayout,
627
- // this
628
- // );
629
- } else if (signupItem.name.startsWith("Text ")) {
630
- return <div dangerouslySetInnerHTML={{ __html: signupItem.label }} />;
631
- } else if (signupItem.name === "Signup button") {
632
- return (
633
- <form onSubmit={(e) => onSubmit(e, state, application)}>
634
- <button className="btn btn-primary" type="submit">
635
- {t("signup.signUp")}
636
- </button>
637
- &nbsp;&nbsp;{t("signup.haveAccount")}&nbsp;
638
- <a
639
- className="signup-link"
640
- onClick={() => {
641
- const linkInStorage = sessionStorage.getItem("signinUrl");
642
- if (linkInStorage !== null && linkInStorage !== "") {
643
- alert("redirect");
644
- // Setting.goToLinkSoft(this, linkInStorage);
645
- } else {
646
- alert("redirect");
647
- // Setting.redirectToLoginPage(application, this.props.history);
648
- }
649
- }}
650
- >
651
- {t("signup.signInNow")}
652
- </a>
653
- </form>
654
- );
655
- } else if (signupItem.name === "Providers" && application.providers) {
656
- const showForm =
657
- Setting.isPasswordEnabled(application) ||
658
- Setting.isCodeSigninEnabled(application) ||
659
- Setting.isWebAuthnEnabled(application) ||
660
- Setting.isLdapEnabled(application);
661
- if (signupItem.rule === "None" || signupItem.rule === "") {
662
- signupItem.rule = showForm ? "small" : "big";
663
- }
664
- return application.providers
665
- .filter((providerItem) => Setting.isProviderVisible(providerItem))
666
- .map((providerItem) => {
667
- return ProviderButton.renderProviderLogo(
668
- providerItem.provider,
669
- application,
670
- null,
671
- null,
672
- signupItem.rule,
673
- { search: window.location.search }
674
- );
675
- });
676
- }
677
-
678
- return signupItem.name;
679
-
680
- // // else if (signupItem.name === "Country/Region") {
681
- // // return (
682
- // // <FormItem
683
- // // name="country_region"
684
- // // className="signup-country-region"
685
- // // label={
686
- // // signupItem.label ? signupItem.label : t("user:Country/Region")
687
- // // }
688
- // // rules={[
689
- // // {
690
- // // required: required,
691
- // // message: t("signup:Please select your country/region!"),
692
- // // },
693
- // // ]}
694
- // // >
695
- // // <RegionSelect
696
- // // className="signup-region-select"
697
- // // onChange={(value) => {
698
- // // setState({ ...state, region: value });
699
- // // }}
700
- // // />
701
-
702
- // // );
703
- // //}
704
- }
1
+ // https://github.com/casdoor/casdoor/blob/master/web/src/auth/SignupPage.js
2
+
3
+ import React, {
4
+ type FormEvent,
5
+ type InputHTMLAttributes,
6
+ type ReactElement,
7
+ } from "react";
8
+ import type { Application } from "./util/provider";
9
+ import type { SignUpFormState } from "../SignUp";
10
+ import { useTranslation } from "react-i18next";
11
+ import * as Setting from "./util/core";
12
+ import * as AuthBackend from "./util/auth-api";
13
+ import { SendCodeInput } from "./SendCodeInput";
14
+ import * as ProviderButton from "../provider/ProviderButton";
15
+ import * as PasswordChecker from "./PasswordChecker";
16
+ import { AgreementModal } from "./AgreementModal";
17
+ import { signIn } from "auth-astro/client";
18
+ import { TFunction } from "i18next";
19
+
20
+ type Rule = {
21
+ required?: boolean;
22
+ message?: string;
23
+ whitespace?: boolean;
24
+ pattern?: RegExp | string;
25
+ validator?: (ev: any, value: string) => Promise<any>;
26
+ validateTrigger?: string;
27
+ };
28
+
29
+ type FormItemProps = {
30
+ label: string;
31
+ name: string;
32
+ inputEl?: ReactElement;
33
+ rules: Array<Rule>;
34
+ setFieldValue: (name: string, value: any) => void;
35
+ };
36
+
37
+ function FormItem({
38
+ label,
39
+ name,
40
+ rules,
41
+ inputEl,
42
+ setFieldValue,
43
+ onChange,
44
+ ...rest
45
+ }: FormItemProps & Partial<InputHTMLAttributes<HTMLInputElement>>) {
46
+ // if (inputEl) {
47
+ // inputEl.props.name = name;
48
+ // }
49
+ return (
50
+ <label className="form-control w-full max-w-xs" htmlFor={name}>
51
+ <div className="label">
52
+ <span className="label-text">{label}</span>
53
+ </div>
54
+ {inputEl ? (
55
+ inputEl
56
+ ) : (
57
+ <input
58
+ type="text"
59
+ {...rest}
60
+ name={name}
61
+ className="input input-bordered w-full max-w-xs"
62
+ onChange={(e) => {
63
+ setFieldValue(name, e.target.value);
64
+ onChange?.(e);
65
+ }}
66
+ />
67
+ )}
68
+
69
+ <div className="label flex-col">
70
+ {rules?.map((rule, i) => (
71
+ <span className="label-text-alt" key={name + i}>
72
+ {rule.message}
73
+ </span>
74
+ ))}
75
+ </div>
76
+ </label>
77
+ );
78
+ }
79
+
80
+ const getValues = (state: SignUpFormState, application: Application) => {
81
+ // example state
82
+ // const s = {
83
+ // applicationName: null,
84
+ // email: "runalldayandnight@gmail.com",
85
+ // phone: "",
86
+ // emailOrPhoneMode: "",
87
+ // countryCode: "",
88
+ // emailCode: "985028",
89
+ // phoneCode: "",
90
+ // validEmail: true,
91
+ // validPhone: false,
92
+ // region: "",
93
+ // isTermsOfUseVisible: false,
94
+ // termsOfUseContent: "",
95
+ // agreement: true,
96
+ // password: "password",
97
+ // confirm: "password",
98
+ // username: "db",
99
+ // };
100
+ delete state.applicationName;
101
+ delete state.emailOrPhoneMode;
102
+ delete state.isTermsOfUseVisible;
103
+ return {
104
+ application: application.name,
105
+ organization: application.organization,
106
+ plan: null,
107
+ pricing: null,
108
+ ...state,
109
+ };
110
+ };
111
+
112
+ // values is formData json
113
+ const onSubmit = (
114
+ e: FormEvent<HTMLFormElement>,
115
+ state: SignUpFormState,
116
+ application: Application
117
+ ) => {
118
+ e.preventDefault();
119
+
120
+ const values = getValues(state, application);
121
+ console.log(values);
122
+ AuthBackend.signup(values).then((res) => {
123
+ if (res.status === "ok") {
124
+ // the user's id will be returned by `signup()`, if user signup by phone, the `username` in `values` is undefined.
125
+ values.username = res.data.split("/")[1];
126
+ // has prompt page is for like oauth with Google
127
+ if (application && Setting.hasPromptPage(application)) {
128
+ // TODO
129
+ AuthBackend.getAccount("").then((res) => {
130
+ let account = null;
131
+ if (res.status === "ok") {
132
+ account = res.data;
133
+ account.organization = res.data2;
134
+ console.log("account", account);
135
+ // TODO log in
136
+ // Webhooks
137
+ // this.onUpdateAccount(account);
138
+ //Setting.goToLinkSoft(this, this.getResultPath(application, values));
139
+ alert("redirect");
140
+ } else {
141
+ Setting.showMessage("error", `Failed to sign in: ${res.msg}`);
142
+ }
143
+ });
144
+ } else {
145
+ alert("redirect");
146
+ signIn();
147
+ // Setting.goToLinkSoft(this, this.getResultPath(application, values));
148
+ }
149
+ } else {
150
+ Setting.showMessage("error", res.msg);
151
+ }
152
+ });
153
+ };
154
+
155
+ export function renderFormItem(
156
+ application: Application,
157
+ signupItem: any,
158
+ state: SignUpFormState,
159
+ setState: React.Dispatch<React.SetStateAction<SignUpFormState>>,
160
+ t: TFunction<"translation", undefined>
161
+ ) {
162
+ if (!signupItem.visible) {
163
+ return null;
164
+ }
165
+
166
+ const setFieldValue = (name: string, value: any) => {
167
+ //@ts-ignore
168
+ state[name] = value;
169
+ setState(state);
170
+ };
171
+ const required = signupItem.required;
172
+
173
+ if (signupItem.name === "Username") {
174
+ return (
175
+ <FormItem
176
+ name="username"
177
+ className="signup-username"
178
+ label={signupItem.label ? signupItem.label : t("signup.username")}
179
+ rules={[
180
+ {
181
+ required: required,
182
+ message: t("forget.username"),
183
+ whitespace: true,
184
+ },
185
+ ]}
186
+ placeholder={signupItem.placeholder}
187
+ disabled={
188
+ state.invitation !== undefined && state.invitation.username !== ""
189
+ }
190
+ setFieldValue={setFieldValue}
191
+ />
192
+ );
193
+ } else if (signupItem.name === "Display name") {
194
+ if (signupItem.rule === "First, last" && Setting.getLanguage() !== "zh") {
195
+ return (
196
+ <React.Fragment>
197
+ <FormItem
198
+ name="firstName"
199
+ className="signup-first-name"
200
+ label={signupItem.label ? signupItem.label : t("general.firstName")}
201
+ rules={[
202
+ {
203
+ required: required,
204
+ message: t("forget.firstName"),
205
+ whitespace: true,
206
+ },
207
+ ]}
208
+ placeholder={signupItem.placeholder}
209
+ setFieldValue={setFieldValue}
210
+ />
211
+
212
+ <FormItem
213
+ name="lastName"
214
+ className="signup-last-name"
215
+ label={signupItem.label ? signupItem.label : t("general.lastName")}
216
+ rules={[
217
+ {
218
+ required: required,
219
+ message: t("forget.lastName"),
220
+ whitespace: true,
221
+ },
222
+ ]}
223
+ placeholder={signupItem.placeholder}
224
+ setFieldValue={setFieldValue}
225
+ />
226
+ </React.Fragment>
227
+ );
228
+ } else {
229
+ return (
230
+ <FormItem
231
+ name="name"
232
+ className="signup-name"
233
+ label={
234
+ signupItem.label
235
+ ? signupItem.label
236
+ : signupItem.rule === "Real name" ||
237
+ signupItem.rule === "First, last"
238
+ ? t("general.realName")
239
+ : t("general.displayName")
240
+ }
241
+ rules={[
242
+ {
243
+ required: required,
244
+ message:
245
+ signupItem.rule === "Real name" ||
246
+ signupItem.rule === "First, last"
247
+ ? t("forget.realName")
248
+ : t("forget.displayName"),
249
+ whitespace: true,
250
+ },
251
+ ]}
252
+ placeholder={signupItem.placeholder}
253
+ setFieldValue={setFieldValue}
254
+ />
255
+ );
256
+ }
257
+ } else if (signupItem.name === "Affiliation") {
258
+ return (
259
+ <FormItem
260
+ name="affiliation"
261
+ className="signup-affiliation"
262
+ label={signupItem.label ? signupItem.label : t("user.affiliation")}
263
+ rules={[
264
+ {
265
+ required: required,
266
+ message: t("forget.affiliation"),
267
+ whitespace: true,
268
+ },
269
+ ]}
270
+ placeholder={signupItem.placeholder}
271
+ setFieldValue={setFieldValue}
272
+ />
273
+ );
274
+ } else if (signupItem.name === "ID card") {
275
+ return (
276
+ <FormItem
277
+ name="idCard"
278
+ className="signup-idcard"
279
+ label={signupItem.label ? signupItem.label : t("user.idCard")}
280
+ rules={[
281
+ {
282
+ required: required,
283
+ message: t("forget.idCard"),
284
+ whitespace: true,
285
+ },
286
+ {
287
+ required: required,
288
+ pattern: new RegExp(
289
+ /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/,
290
+ "g"
291
+ ),
292
+ message: t("format.idCard"),
293
+ },
294
+ ]}
295
+ placeholder={signupItem.placeholder}
296
+ setFieldValue={setFieldValue}
297
+ />
298
+ );
299
+ } else if (
300
+ signupItem.name === "Email" ||
301
+ signupItem.name === "Phone" ||
302
+ signupItem.name === "Email or Phone" ||
303
+ signupItem.name === "Phone or Email"
304
+ ) {
305
+ const renderEmailItem = () => {
306
+ return (
307
+ <React.Fragment>
308
+ <FormItem
309
+ name="email"
310
+ // className="signup-email"
311
+ label={signupItem.label ? signupItem.label : t("general.email")}
312
+ rules={[
313
+ {
314
+ required: required,
315
+ message: t("forget.email"),
316
+ },
317
+ ]}
318
+ placeholder={signupItem.placeholder}
319
+ disabled={
320
+ state.invitation !== undefined && state.invitation.email !== ""
321
+ }
322
+ onChange={(e: any) => {
323
+ const email = e.target.value;
324
+ console.log("email", email, Setting.isValidEmail(email));
325
+ if (email !== "" && !Setting.isValidEmail(email)) {
326
+ setState({ ...state, email, validEmail: false });
327
+ } else {
328
+ setState({ ...state, email, validEmail: true });
329
+ }
330
+ }}
331
+ setFieldValue={setFieldValue}
332
+ />
333
+
334
+ {signupItem.rule !== "No verification" && (
335
+ <FormItem
336
+ name="emailCode"
337
+ className="signup-email-code"
338
+ label={signupItem.label ? signupItem.label : t("code.email")}
339
+ rules={[
340
+ {
341
+ required: required,
342
+ message: t("forget.code"),
343
+ },
344
+ ]}
345
+ inputEl={
346
+ <SendCodeInput
347
+ // className="signup-email-code-input"
348
+ disabled={!state.validEmail}
349
+ method={"signup"}
350
+ onButtonClickArgs={[state.email, "email", application.name]}
351
+ application={application}
352
+ countryCode="US"
353
+ onChange={(value: string) =>
354
+ setState({ ...state, emailCode: value })
355
+ }
356
+ />
357
+ }
358
+ setFieldValue={setFieldValue}
359
+ />
360
+ )}
361
+ </React.Fragment>
362
+ );
363
+ };
364
+
365
+ const renderPhoneItem = () => {
366
+ return <></>;
367
+ // return (
368
+ // <React.Fragment>
369
+ // <FormItem
370
+ // className="signup-phone"
371
+ // label={
372
+ // signupItem.label ? signupItem.label : t("general:Phone")
373
+ // }
374
+ // required={required}
375
+ // >
376
+ // <Input.Group compact>
377
+ // <FormItem
378
+ // name="countryCode"
379
+ // noStyle
380
+ // rules={[
381
+ // {
382
+ // required: required,
383
+ // message: t(
384
+ // "signup:Please select your country code!"
385
+ // ),
386
+ // },
387
+ // ]}
388
+ // >
389
+ // <CountryCodeSelect
390
+ // style={{ width: "35%" }}
391
+ // countryCodes={
392
+ // this.getApplicationObj().organizationObj.countryCodes
393
+ // }
394
+ // />
395
+
396
+ // <FormItem
397
+ // name="phone"
398
+ // dependencies={["countryCode"]}
399
+ // noStyle
400
+ // rules={[
401
+ // {
402
+ // required: required,
403
+ // message: t(
404
+ // "signup:Please input your phone number!"
405
+ // ),
406
+ // },
407
+ // ({ getFieldValue }) => ({
408
+ // validator: (_, value) => {
409
+ // if (!required && !value) {
410
+ // return Promise.resolve();
411
+ // }
412
+
413
+ // if (
414
+ // value &&
415
+ // !Setting.isValidPhone(
416
+ // value,
417
+ // getFieldValue("countryCode")
418
+ // )
419
+ // ) {
420
+ // setState({ ...state, validPhone: false });
421
+ // return Promise.reject(
422
+ // t("signup:The input is not valid Phone!")
423
+ // );
424
+ // }
425
+
426
+ // setState({ ...state, validPhone: true });
427
+ // return Promise.resolve();
428
+ // },
429
+ // }),
430
+ // ]}
431
+ // >
432
+ // <Input
433
+ // className="signup-phone-input"
434
+ // placeholder={signupItem.placeholder}
435
+ // style={{ width: "65%" }}
436
+ // disabled={
437
+ // state.invitation !== undefined &&
438
+ // state.invitation.phone !== ""
439
+ // }
440
+ // onChange={(e) =>
441
+ // setState({ ...state, phone: e.target.value })
442
+ // }
443
+ // />
444
+
445
+ // </Input.Group>
446
+
447
+ // {signupItem.rule !== "No verification" && (
448
+ // <FormItem
449
+ // name="phoneCode"
450
+ // className="phone-code"
451
+ // label={
452
+ // signupItem.label
453
+ // ? signupItem.label
454
+ // : t("code:Phone code")
455
+ // }
456
+ // rules={[
457
+ // {
458
+ // required: required,
459
+ // message: t(
460
+ // "code:Please input your phone verification code!"
461
+ // ),
462
+ // },
463
+ // ]}
464
+ // >
465
+ // <SendCodeInput
466
+ // className="signup-phone-code-input"
467
+ // disabled={!state.validPhone}
468
+ // method={"signup"}
469
+ // onButtonClickArgs={[
470
+ // state.phone,
471
+ // "phone",
472
+ // Setting.getApplicationName(application),
473
+ // ]}
474
+ // application={application}
475
+ // countryCode={this.form.current?.getFieldValue("countryCode")}
476
+ // />
477
+
478
+ // )}
479
+ // </React.Fragment>
480
+ // );
481
+ };
482
+
483
+ if (signupItem.name === "Email") {
484
+ return renderEmailItem();
485
+ } else if (signupItem.name === "Phone") {
486
+ return renderPhoneItem();
487
+ } else if (
488
+ signupItem.name === "Email or Phone" ||
489
+ signupItem.name === "Phone or Email"
490
+ ) {
491
+ let emailOrPhoneMode = state.emailOrPhoneMode;
492
+ if (emailOrPhoneMode === "") {
493
+ emailOrPhoneMode =
494
+ signupItem.name === "Email or Phone" ? "Email" : "Phone";
495
+ }
496
+
497
+ return (
498
+ <React.Fragment>
499
+ <div style={{ marginTop: "30px", marginBottom: "20px" }}>
500
+ {/* <Radio.Group
501
+ style={{ width: "400px" }}
502
+ buttonStyle="solid"
503
+ onChange={(e) => {
504
+ setState({ ...state, emailOrPhoneMode: e.target.value });
505
+ }}
506
+ value={emailOrPhoneMode}
507
+ >
508
+ {signupItem.name === "Email or Phone" ? (
509
+ <React.Fragment>
510
+ <Radio.Button value={"Email"}>
511
+ {t("general:Email")}
512
+ </Radio.Button>
513
+ <Radio.Button value={"Phone"}>
514
+ {t("general:Phone")}
515
+ </Radio.Button>
516
+ </React.Fragment>
517
+ ) : (
518
+ <React.Fragment>
519
+ <Radio.Button value={"Phone"}>
520
+ {t("general:Phone")}
521
+ </Radio.Button>
522
+ <Radio.Button value={"Email"}>
523
+ {t("general:Email")}
524
+ </Radio.Button>
525
+ </React.Fragment>
526
+ )}
527
+ </Radio.Group> */}
528
+ </div>
529
+ {emailOrPhoneMode === "Email" ? renderEmailItem() : renderPhoneItem()}
530
+ </React.Fragment>
531
+ );
532
+ } else {
533
+ return null;
534
+ }
535
+ } else if (signupItem.name === "Password") {
536
+ return (
537
+ <FormItem
538
+ name="password"
539
+ className="signup-password"
540
+ label={signupItem.label ? signupItem.label : t("general.password")}
541
+ rules={[
542
+ {
543
+ required: required,
544
+ validateTrigger: "onChange",
545
+ validator: (rule, value) => {
546
+ const errorMsg = PasswordChecker.checkPasswordComplexity(
547
+ value,
548
+ application.organizationObj.passwordOptions
549
+ );
550
+ if (errorMsg === "") {
551
+ return Promise.resolve();
552
+ } else {
553
+ return Promise.reject(errorMsg);
554
+ }
555
+ },
556
+ },
557
+ ]}
558
+ setFieldValue={setFieldValue}
559
+ // hasFeedback
560
+ type="password"
561
+ placeholder={signupItem.placeholder}
562
+ />
563
+ );
564
+ } else if (signupItem.name === "Confirm password") {
565
+ return (
566
+ <FormItem
567
+ name="confirm"
568
+ className="signup-confirm"
569
+ label={signupItem.label ? signupItem.label : t("signup.confirm")}
570
+ // dependencies={["password"]}
571
+ // hasFeedback
572
+ rules={[
573
+ {
574
+ required: required,
575
+ message: t("forget.confirm"),
576
+ },
577
+ // ({ getFieldValue }) => ({
578
+ // validator(rule, value) {
579
+ // if (!value || getFieldValue("password") === value) {
580
+ // return Promise.resolve();
581
+ // }
582
+
583
+ // return Promise.reject(
584
+ // t(
585
+ // "signup:Your confirmed password is inconsistent with the password!"
586
+ // )
587
+ // );
588
+ // },
589
+ // }),
590
+ ]}
591
+ type="password"
592
+ placeholder={signupItem.placeholder}
593
+ setFieldValue={setFieldValue}
594
+ />
595
+ );
596
+ } else if (signupItem.name === "Invitation code") {
597
+ return (
598
+ <FormItem
599
+ name="invitationCode"
600
+ className="signup-invitation-code"
601
+ label={
602
+ signupItem.label ? signupItem.label : t("application.invitationCode")
603
+ }
604
+ rules={[
605
+ {
606
+ required: required,
607
+ message: t("forget.invitationCode"),
608
+ },
609
+ ]}
610
+ placeholder={signupItem.placeholder}
611
+ disabled={state.invitation !== undefined && state.invitation !== ""}
612
+ setFieldValue={setFieldValue}
613
+ />
614
+ );
615
+ } else if (signupItem.name === "Agreement") {
616
+ return (
617
+ <AgreementModal
618
+ state={state}
619
+ setState={setState}
620
+ application={application}
621
+ />
622
+ );
623
+ // return AgreementModal.renderAgreementFormItem(
624
+ // application,
625
+ // required,
626
+ // tailFormItemLayout,
627
+ // this
628
+ // );
629
+ } else if (signupItem.name.startsWith("Text ")) {
630
+ return <div dangerouslySetInnerHTML={{ __html: signupItem.label }} />;
631
+ } else if (signupItem.name === "Signup button") {
632
+ return (
633
+ <form onSubmit={(e) => onSubmit(e, state, application)}>
634
+ <button className="btn btn-primary" type="submit">
635
+ {t("signup.signUp")}
636
+ </button>
637
+ &nbsp;&nbsp;{t("signup.haveAccount")}&nbsp;
638
+ <a
639
+ className="signup-link"
640
+ onClick={() => {
641
+ const linkInStorage = sessionStorage.getItem("signinUrl");
642
+ if (linkInStorage !== null && linkInStorage !== "") {
643
+ alert("redirect");
644
+ // Setting.goToLinkSoft(this, linkInStorage);
645
+ } else {
646
+ alert("redirect");
647
+ // Setting.redirectToLoginPage(application, this.props.history);
648
+ }
649
+ }}
650
+ >
651
+ {t("signup.signInNow")}
652
+ </a>
653
+ </form>
654
+ );
655
+ } else if (signupItem.name === "Providers" && application.providers) {
656
+ const showForm =
657
+ Setting.isPasswordEnabled(application) ||
658
+ Setting.isCodeSigninEnabled(application) ||
659
+ Setting.isWebAuthnEnabled(application) ||
660
+ Setting.isLdapEnabled(application);
661
+ if (signupItem.rule === "None" || signupItem.rule === "") {
662
+ signupItem.rule = showForm ? "small" : "big";
663
+ }
664
+ return application.providers
665
+ .filter((providerItem) => Setting.isProviderVisible(providerItem))
666
+ .map((providerItem) => {
667
+ return ProviderButton.renderProviderLogo(
668
+ providerItem.provider,
669
+ application,
670
+ null,
671
+ null,
672
+ signupItem.rule,
673
+ { search: window.location.search }
674
+ );
675
+ });
676
+ }
677
+
678
+ return signupItem.name;
679
+
680
+ // // else if (signupItem.name === "Country/Region") {
681
+ // // return (
682
+ // // <FormItem
683
+ // // name="country_region"
684
+ // // className="signup-country-region"
685
+ // // label={
686
+ // // signupItem.label ? signupItem.label : t("user:Country/Region")
687
+ // // }
688
+ // // rules={[
689
+ // // {
690
+ // // required: required,
691
+ // // message: t("signup:Please select your country/region!"),
692
+ // // },
693
+ // // ]}
694
+ // // >
695
+ // // <RegionSelect
696
+ // // className="signup-region-select"
697
+ // // onChange={(value) => {
698
+ // // setState({ ...state, region: value });
699
+ // // }}
700
+ // // />
701
+
702
+ // // );
703
+ // //}
704
+ }