@springmicro/auth 0.5.1 → 0.5.3

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 (143) hide show
  1. package/.eslintrc.cjs +18 -18
  2. package/README.md +60 -60
  3. package/dist/{Index-64ac63ff-Bb7oVTBw.js → Index-64ac63ff-CSMaEBDA.js} +1 -1
  4. package/dist/{Index-6c094240-Cre9O000.js → Index-6c094240-mSgidTC1.js} +1 -1
  5. package/dist/{Web3Auth-D-jzK5S2.js → Web3Auth-R27O2eCc.js} +10 -10
  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-1XTFjS64.js → hashMessage-B7KFzddV.js} +1 -1
  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 +0 -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-BcBHeHDh.js → index-1HLXgKdW.js} +2 -2
  41. package/dist/index-40a497ea-Bn2mC0r7.js +0 -0
  42. package/dist/{index-Bt-ptciq.js → index-C8xLRoDS.js} +1 -1
  43. package/dist/{index-Dd6Cx4jI.js → index-ChYsa81u.js} +2 -2
  44. package/dist/{index-Bi-yyFKX.js → index-Cp0Pai1C.js} +1 -1
  45. package/dist/{index-BCIsepdu.js → index-D_yyUC2r.js} +1060 -1025
  46. package/dist/{index-m_M0OdCv.js → index-TsElTuix.js} +1 -1
  47. package/dist/{index-D23L6orl.js → index-ayOaYQgv.js} +4 -4
  48. package/dist/index.d.ts +8 -3
  49. package/dist/index.js +1 -1
  50. package/dist/index.umd.cjs +165 -165
  51. package/dist/infinitywallet-C8J4FUYw.js +0 -0
  52. package/dist/kayros-AIrUK1za.js +0 -0
  53. package/dist/keplr-CyLTca9B.js +0 -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 +0 -0
  61. package/dist/{number-DcOvM-ZJ.js → number-D9Q-3_Cz.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 +0 -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 +13 -13
  89. package/package.json +2 -2
  90. package/src/auth/config.ts +91 -91
  91. package/src/components/SignUp.tsx +472 -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 +155 -149
  98. package/src/components/forms/SignUpFormItem.tsx +708 -704
  99. package/src/components/forms/util/application-api.ts +161 -157
  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 +311 -307
  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 +174 -170
  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 +1 -1
  141. package/tsconfig.json +23 -23
  142. package/tsconfig.node.json +10 -10
  143. package/vite.config.ts +33 -33
@@ -1,704 +1,708 @@
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
+ CLIENT_ID: string,
162
+ CLIENT_SECRET: string
163
+ ) {
164
+ if (!signupItem.visible) {
165
+ return null;
166
+ }
167
+
168
+ const setFieldValue = (name: string, value: any) => {
169
+ //@ts-ignore
170
+ state[name] = value;
171
+ setState(state);
172
+ };
173
+ const required = signupItem.required;
174
+
175
+ if (signupItem.name === "Username") {
176
+ return (
177
+ <FormItem
178
+ name="username"
179
+ className="signup-username"
180
+ label={signupItem.label ? signupItem.label : t("signup.username")}
181
+ rules={[
182
+ {
183
+ required: required,
184
+ message: t("forget.username"),
185
+ whitespace: true,
186
+ },
187
+ ]}
188
+ placeholder={signupItem.placeholder}
189
+ disabled={
190
+ state.invitation !== undefined && state.invitation.username !== ""
191
+ }
192
+ setFieldValue={setFieldValue}
193
+ />
194
+ );
195
+ } else if (signupItem.name === "Display name") {
196
+ if (signupItem.rule === "First, last" && Setting.getLanguage() !== "zh") {
197
+ return (
198
+ <React.Fragment>
199
+ <FormItem
200
+ name="firstName"
201
+ className="signup-first-name"
202
+ label={signupItem.label ? signupItem.label : t("general.firstName")}
203
+ rules={[
204
+ {
205
+ required: required,
206
+ message: t("forget.firstName"),
207
+ whitespace: true,
208
+ },
209
+ ]}
210
+ placeholder={signupItem.placeholder}
211
+ setFieldValue={setFieldValue}
212
+ />
213
+
214
+ <FormItem
215
+ name="lastName"
216
+ className="signup-last-name"
217
+ label={signupItem.label ? signupItem.label : t("general.lastName")}
218
+ rules={[
219
+ {
220
+ required: required,
221
+ message: t("forget.lastName"),
222
+ whitespace: true,
223
+ },
224
+ ]}
225
+ placeholder={signupItem.placeholder}
226
+ setFieldValue={setFieldValue}
227
+ />
228
+ </React.Fragment>
229
+ );
230
+ } else {
231
+ return (
232
+ <FormItem
233
+ name="name"
234
+ className="signup-name"
235
+ label={
236
+ signupItem.label
237
+ ? signupItem.label
238
+ : signupItem.rule === "Real name" ||
239
+ signupItem.rule === "First, last"
240
+ ? t("general.realName")
241
+ : t("general.displayName")
242
+ }
243
+ rules={[
244
+ {
245
+ required: required,
246
+ message:
247
+ signupItem.rule === "Real name" ||
248
+ signupItem.rule === "First, last"
249
+ ? t("forget.realName")
250
+ : t("forget.displayName"),
251
+ whitespace: true,
252
+ },
253
+ ]}
254
+ placeholder={signupItem.placeholder}
255
+ setFieldValue={setFieldValue}
256
+ />
257
+ );
258
+ }
259
+ } else if (signupItem.name === "Affiliation") {
260
+ return (
261
+ <FormItem
262
+ name="affiliation"
263
+ className="signup-affiliation"
264
+ label={signupItem.label ? signupItem.label : t("user.affiliation")}
265
+ rules={[
266
+ {
267
+ required: required,
268
+ message: t("forget.affiliation"),
269
+ whitespace: true,
270
+ },
271
+ ]}
272
+ placeholder={signupItem.placeholder}
273
+ setFieldValue={setFieldValue}
274
+ />
275
+ );
276
+ } else if (signupItem.name === "ID card") {
277
+ return (
278
+ <FormItem
279
+ name="idCard"
280
+ className="signup-idcard"
281
+ label={signupItem.label ? signupItem.label : t("user.idCard")}
282
+ rules={[
283
+ {
284
+ required: required,
285
+ message: t("forget.idCard"),
286
+ whitespace: true,
287
+ },
288
+ {
289
+ required: required,
290
+ pattern: new RegExp(
291
+ /^[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]$/,
292
+ "g"
293
+ ),
294
+ message: t("format.idCard"),
295
+ },
296
+ ]}
297
+ placeholder={signupItem.placeholder}
298
+ setFieldValue={setFieldValue}
299
+ />
300
+ );
301
+ } else if (
302
+ signupItem.name === "Email" ||
303
+ signupItem.name === "Phone" ||
304
+ signupItem.name === "Email or Phone" ||
305
+ signupItem.name === "Phone or Email"
306
+ ) {
307
+ const renderEmailItem = () => {
308
+ return (
309
+ <React.Fragment>
310
+ <FormItem
311
+ name="email"
312
+ // className="signup-email"
313
+ label={signupItem.label ? signupItem.label : t("general.email")}
314
+ rules={[
315
+ {
316
+ required: required,
317
+ message: t("forget.email"),
318
+ },
319
+ ]}
320
+ placeholder={signupItem.placeholder}
321
+ disabled={
322
+ state.invitation !== undefined && state.invitation.email !== ""
323
+ }
324
+ onChange={(e: any) => {
325
+ const email = e.target.value;
326
+ console.log("email", email, Setting.isValidEmail(email));
327
+ if (email !== "" && !Setting.isValidEmail(email)) {
328
+ setState({ ...state, email, validEmail: false });
329
+ } else {
330
+ setState({ ...state, email, validEmail: true });
331
+ }
332
+ }}
333
+ setFieldValue={setFieldValue}
334
+ />
335
+
336
+ {signupItem.rule !== "No verification" && (
337
+ <FormItem
338
+ name="emailCode"
339
+ className="signup-email-code"
340
+ label={signupItem.label ? signupItem.label : t("code.email")}
341
+ rules={[
342
+ {
343
+ required: required,
344
+ message: t("forget.code"),
345
+ },
346
+ ]}
347
+ inputEl={
348
+ <SendCodeInput
349
+ // className="signup-email-code-input"
350
+ disabled={!state.validEmail}
351
+ method={"signup"}
352
+ onButtonClickArgs={[state.email, "email", application.name]}
353
+ application={application}
354
+ countryCode="US"
355
+ onChange={(value: string) =>
356
+ setState({ ...state, emailCode: value })
357
+ }
358
+ CLIENT_ID={CLIENT_ID}
359
+ CLIENT_SECRET={CLIENT_SECRET}
360
+ />
361
+ }
362
+ setFieldValue={setFieldValue}
363
+ />
364
+ )}
365
+ </React.Fragment>
366
+ );
367
+ };
368
+
369
+ const renderPhoneItem = () => {
370
+ return <></>;
371
+ // return (
372
+ // <React.Fragment>
373
+ // <FormItem
374
+ // className="signup-phone"
375
+ // label={
376
+ // signupItem.label ? signupItem.label : t("general:Phone")
377
+ // }
378
+ // required={required}
379
+ // >
380
+ // <Input.Group compact>
381
+ // <FormItem
382
+ // name="countryCode"
383
+ // noStyle
384
+ // rules={[
385
+ // {
386
+ // required: required,
387
+ // message: t(
388
+ // "signup:Please select your country code!"
389
+ // ),
390
+ // },
391
+ // ]}
392
+ // >
393
+ // <CountryCodeSelect
394
+ // style={{ width: "35%" }}
395
+ // countryCodes={
396
+ // this.getApplicationObj().organizationObj.countryCodes
397
+ // }
398
+ // />
399
+
400
+ // <FormItem
401
+ // name="phone"
402
+ // dependencies={["countryCode"]}
403
+ // noStyle
404
+ // rules={[
405
+ // {
406
+ // required: required,
407
+ // message: t(
408
+ // "signup:Please input your phone number!"
409
+ // ),
410
+ // },
411
+ // ({ getFieldValue }) => ({
412
+ // validator: (_, value) => {
413
+ // if (!required && !value) {
414
+ // return Promise.resolve();
415
+ // }
416
+
417
+ // if (
418
+ // value &&
419
+ // !Setting.isValidPhone(
420
+ // value,
421
+ // getFieldValue("countryCode")
422
+ // )
423
+ // ) {
424
+ // setState({ ...state, validPhone: false });
425
+ // return Promise.reject(
426
+ // t("signup:The input is not valid Phone!")
427
+ // );
428
+ // }
429
+
430
+ // setState({ ...state, validPhone: true });
431
+ // return Promise.resolve();
432
+ // },
433
+ // }),
434
+ // ]}
435
+ // >
436
+ // <Input
437
+ // className="signup-phone-input"
438
+ // placeholder={signupItem.placeholder}
439
+ // style={{ width: "65%" }}
440
+ // disabled={
441
+ // state.invitation !== undefined &&
442
+ // state.invitation.phone !== ""
443
+ // }
444
+ // onChange={(e) =>
445
+ // setState({ ...state, phone: e.target.value })
446
+ // }
447
+ // />
448
+
449
+ // </Input.Group>
450
+
451
+ // {signupItem.rule !== "No verification" && (
452
+ // <FormItem
453
+ // name="phoneCode"
454
+ // className="phone-code"
455
+ // label={
456
+ // signupItem.label
457
+ // ? signupItem.label
458
+ // : t("code:Phone code")
459
+ // }
460
+ // rules={[
461
+ // {
462
+ // required: required,
463
+ // message: t(
464
+ // "code:Please input your phone verification code!"
465
+ // ),
466
+ // },
467
+ // ]}
468
+ // >
469
+ // <SendCodeInput
470
+ // className="signup-phone-code-input"
471
+ // disabled={!state.validPhone}
472
+ // method={"signup"}
473
+ // onButtonClickArgs={[
474
+ // state.phone,
475
+ // "phone",
476
+ // Setting.getApplicationName(application),
477
+ // ]}
478
+ // application={application}
479
+ // countryCode={this.form.current?.getFieldValue("countryCode")}
480
+ // />
481
+
482
+ // )}
483
+ // </React.Fragment>
484
+ // );
485
+ };
486
+
487
+ if (signupItem.name === "Email") {
488
+ return renderEmailItem();
489
+ } else if (signupItem.name === "Phone") {
490
+ return renderPhoneItem();
491
+ } else if (
492
+ signupItem.name === "Email or Phone" ||
493
+ signupItem.name === "Phone or Email"
494
+ ) {
495
+ let emailOrPhoneMode = state.emailOrPhoneMode;
496
+ if (emailOrPhoneMode === "") {
497
+ emailOrPhoneMode =
498
+ signupItem.name === "Email or Phone" ? "Email" : "Phone";
499
+ }
500
+
501
+ return (
502
+ <React.Fragment>
503
+ <div style={{ marginTop: "30px", marginBottom: "20px" }}>
504
+ {/* <Radio.Group
505
+ style={{ width: "400px" }}
506
+ buttonStyle="solid"
507
+ onChange={(e) => {
508
+ setState({ ...state, emailOrPhoneMode: e.target.value });
509
+ }}
510
+ value={emailOrPhoneMode}
511
+ >
512
+ {signupItem.name === "Email or Phone" ? (
513
+ <React.Fragment>
514
+ <Radio.Button value={"Email"}>
515
+ {t("general:Email")}
516
+ </Radio.Button>
517
+ <Radio.Button value={"Phone"}>
518
+ {t("general:Phone")}
519
+ </Radio.Button>
520
+ </React.Fragment>
521
+ ) : (
522
+ <React.Fragment>
523
+ <Radio.Button value={"Phone"}>
524
+ {t("general:Phone")}
525
+ </Radio.Button>
526
+ <Radio.Button value={"Email"}>
527
+ {t("general:Email")}
528
+ </Radio.Button>
529
+ </React.Fragment>
530
+ )}
531
+ </Radio.Group> */}
532
+ </div>
533
+ {emailOrPhoneMode === "Email" ? renderEmailItem() : renderPhoneItem()}
534
+ </React.Fragment>
535
+ );
536
+ } else {
537
+ return null;
538
+ }
539
+ } else if (signupItem.name === "Password") {
540
+ return (
541
+ <FormItem
542
+ name="password"
543
+ className="signup-password"
544
+ label={signupItem.label ? signupItem.label : t("general.password")}
545
+ rules={[
546
+ {
547
+ required: required,
548
+ validateTrigger: "onChange",
549
+ validator: (rule, value) => {
550
+ const errorMsg = PasswordChecker.checkPasswordComplexity(
551
+ value,
552
+ application.organizationObj.passwordOptions
553
+ );
554
+ if (errorMsg === "") {
555
+ return Promise.resolve();
556
+ } else {
557
+ return Promise.reject(errorMsg);
558
+ }
559
+ },
560
+ },
561
+ ]}
562
+ setFieldValue={setFieldValue}
563
+ // hasFeedback
564
+ type="password"
565
+ placeholder={signupItem.placeholder}
566
+ />
567
+ );
568
+ } else if (signupItem.name === "Confirm password") {
569
+ return (
570
+ <FormItem
571
+ name="confirm"
572
+ className="signup-confirm"
573
+ label={signupItem.label ? signupItem.label : t("signup.confirm")}
574
+ // dependencies={["password"]}
575
+ // hasFeedback
576
+ rules={[
577
+ {
578
+ required: required,
579
+ message: t("forget.confirm"),
580
+ },
581
+ // ({ getFieldValue }) => ({
582
+ // validator(rule, value) {
583
+ // if (!value || getFieldValue("password") === value) {
584
+ // return Promise.resolve();
585
+ // }
586
+
587
+ // return Promise.reject(
588
+ // t(
589
+ // "signup:Your confirmed password is inconsistent with the password!"
590
+ // )
591
+ // );
592
+ // },
593
+ // }),
594
+ ]}
595
+ type="password"
596
+ placeholder={signupItem.placeholder}
597
+ setFieldValue={setFieldValue}
598
+ />
599
+ );
600
+ } else if (signupItem.name === "Invitation code") {
601
+ return (
602
+ <FormItem
603
+ name="invitationCode"
604
+ className="signup-invitation-code"
605
+ label={
606
+ signupItem.label ? signupItem.label : t("application.invitationCode")
607
+ }
608
+ rules={[
609
+ {
610
+ required: required,
611
+ message: t("forget.invitationCode"),
612
+ },
613
+ ]}
614
+ placeholder={signupItem.placeholder}
615
+ disabled={state.invitation !== undefined && state.invitation !== ""}
616
+ setFieldValue={setFieldValue}
617
+ />
618
+ );
619
+ } else if (signupItem.name === "Agreement") {
620
+ return (
621
+ <AgreementModal
622
+ state={state}
623
+ setState={setState}
624
+ application={application}
625
+ />
626
+ );
627
+ // return AgreementModal.renderAgreementFormItem(
628
+ // application,
629
+ // required,
630
+ // tailFormItemLayout,
631
+ // this
632
+ // );
633
+ } else if (signupItem.name.startsWith("Text ")) {
634
+ return <div dangerouslySetInnerHTML={{ __html: signupItem.label }} />;
635
+ } else if (signupItem.name === "Signup button") {
636
+ return (
637
+ <form onSubmit={(e) => onSubmit(e, state, application)}>
638
+ <button className="btn btn-primary" type="submit">
639
+ {t("signup.signUp")}
640
+ </button>
641
+ &nbsp;&nbsp;{t("signup.haveAccount")}&nbsp;
642
+ <a
643
+ className="signup-link"
644
+ onClick={() => {
645
+ const linkInStorage = sessionStorage.getItem("signinUrl");
646
+ if (linkInStorage !== null && linkInStorage !== "") {
647
+ alert("redirect");
648
+ // Setting.goToLinkSoft(this, linkInStorage);
649
+ } else {
650
+ alert("redirect");
651
+ // Setting.redirectToLoginPage(application, this.props.history);
652
+ }
653
+ }}
654
+ >
655
+ {t("signup.signInNow")}
656
+ </a>
657
+ </form>
658
+ );
659
+ } else if (signupItem.name === "Providers" && application.providers) {
660
+ const showForm =
661
+ Setting.isPasswordEnabled(application) ||
662
+ Setting.isCodeSigninEnabled(application) ||
663
+ Setting.isWebAuthnEnabled(application) ||
664
+ Setting.isLdapEnabled(application);
665
+ if (signupItem.rule === "None" || signupItem.rule === "") {
666
+ signupItem.rule = showForm ? "small" : "big";
667
+ }
668
+ return application.providers
669
+ .filter((providerItem) => Setting.isProviderVisible(providerItem))
670
+ .map((providerItem) => {
671
+ return ProviderButton.renderProviderLogo(
672
+ providerItem.provider,
673
+ application,
674
+ null,
675
+ null,
676
+ signupItem.rule,
677
+ { search: window.location.search }
678
+ );
679
+ });
680
+ }
681
+
682
+ return signupItem.name;
683
+
684
+ // // else if (signupItem.name === "Country/Region") {
685
+ // // return (
686
+ // // <FormItem
687
+ // // name="country_region"
688
+ // // className="signup-country-region"
689
+ // // label={
690
+ // // signupItem.label ? signupItem.label : t("user:Country/Region")
691
+ // // }
692
+ // // rules={[
693
+ // // {
694
+ // // required: required,
695
+ // // message: t("signup:Please select your country/region!"),
696
+ // // },
697
+ // // ]}
698
+ // // >
699
+ // // <RegionSelect
700
+ // // className="signup-region-select"
701
+ // // onChange={(value) => {
702
+ // // setState({ ...state, region: value });
703
+ // // }}
704
+ // // />
705
+
706
+ // // );
707
+ // //}
708
+ }