@springmicro/auth 0.1.8 → 0.2.0-alpha.0

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 (136) hide show
  1. package/README.md +20 -15
  2. package/dist/Index-652aeb8c-BTQ1rBi7.js +2818 -0
  3. package/dist/Index-c419311f-BOZhAAW3.js +1054 -0
  4. package/dist/Web3Auth-hACKSouN.js +32769 -0
  5. package/dist/alphawallet-B7eovdf-.js +26 -0
  6. package/dist/apexwallet-ysP20G9D.js +93 -0
  7. package/dist/atoken-BBnNTzcz.js +27 -0
  8. package/dist/bifrostwallet-CNNBO92h.js +11 -0
  9. package/dist/binance-DvPgAzCw.js +14 -0
  10. package/dist/bitget-DZOUrwgy.js +4 -0
  11. package/dist/bitpie-C_uxmEzw.js +25 -0
  12. package/dist/bitski-DpzkHNkv.js +4 -0
  13. package/dist/blockwallet-BL69cqkA.js +8 -0
  14. package/dist/brave-DnRzMQYW.js +35 -0
  15. package/dist/ccip-c78d2f16-DLcRlwod.js +165 -0
  16. package/dist/coin98wallet-CkFdOvXt.js +4 -0
  17. package/dist/coinbase-CaGNx5if.js +9 -0
  18. package/dist/core-9rK8tWud.js +7 -0
  19. package/dist/defiwallet-0AsgJBSy.js +10 -0
  20. package/dist/detected-CX_JZaUk.js +6 -0
  21. package/dist/echooo-CmaetT_Z.js +14 -0
  22. package/dist/enkrypt-BibtwvK7.js +20 -0
  23. package/dist/exodus-BxzkDWWP.js +4 -0
  24. package/dist/fordefi-CvKyVwhI.js +6 -0
  25. package/dist/foxwallet-D7c_LDTf.js +4 -0
  26. package/dist/frame-CDfNmjUy.js +7 -0
  27. package/dist/frontier-DqKNSj2z.js +8 -0
  28. package/dist/huobiwallet-CxSwqa5L.js +14 -0
  29. package/dist/hyperpay-nmHE3WqM.js +7 -0
  30. package/dist/icon-2Zqy7pqQ.js +8 -0
  31. package/dist/icon-CGWI1Ies.js +43 -0
  32. package/dist/icon-C_O4nprO.js +9 -0
  33. package/dist/icon-DbgmZCnU.js +9 -0
  34. package/dist/icon-cAd7RhSC.js +9 -0
  35. package/dist/icon-duCa3gfT.js +11 -0
  36. package/dist/imtoken-yENtOTS3.js +17 -0
  37. package/dist/index-021f6a62-Zz543EDB.js +2583 -0
  38. package/dist/index-40a497ea-Bn2mC0r7.js +1010 -0
  39. package/dist/index-BHkXn9Ss.js +4010 -0
  40. package/dist/index-BaYEABY7.js +7089 -0
  41. package/dist/index-BtLU53lm.js +6023 -0
  42. package/dist/index-CynP9H3X.js +6188 -0
  43. package/dist/index-Dg8m-Szw.js +31 -0
  44. package/dist/index-Dt6M8ha9.js +161 -0
  45. package/dist/index-DtJfAdfq.js +5822 -0
  46. package/dist/index-klU8YB0c.js +1983 -0
  47. package/dist/index.d.ts +124 -0
  48. package/dist/index.js +5 -43
  49. package/dist/index.umd.cjs +1937 -1
  50. package/dist/infinitywallet-C8J4FUYw.js +42 -0
  51. package/dist/kayros-AIrUK1za.js +27 -0
  52. package/dist/lif3wallet-C5D6r8pg.js +41 -0
  53. package/dist/liquality-nbCtErVq.js +16 -0
  54. package/dist/mathwallet-CWkivCXo.js +50 -0
  55. package/dist/meetone-kKmvI8md.js +13 -0
  56. package/dist/metamask-BN7yiDV1.js +64 -0
  57. package/dist/mykey-CQZ6UcLH.js +13 -0
  58. package/dist/number-BXHWhlom.js +1529 -0
  59. package/dist/okxwallet-CJLVogh2.js +8 -0
  60. package/dist/oneInch-CciyZ4Pz.js +72 -0
  61. package/dist/onekey-Dal8kYjU.js +9 -0
  62. package/dist/opera-DnKg-TJU.js +24 -0
  63. package/dist/ownbit-BshJUVuW.js +18 -0
  64. package/dist/phantom-CJ8dIcov.js +35 -0
  65. package/dist/rabby-D4thTcd6.js +27 -0
  66. package/dist/rainbow-mXld6yWV.js +69 -0
  67. package/dist/roninwallet-ZyYrd-D1.js +9 -0
  68. package/dist/safeheron-Eg1Jb29V.js +23 -0
  69. package/dist/safepal-DVIKy94N.js +105 -0
  70. package/dist/sequence-BS2IbtDg.js +70 -0
  71. package/dist/stablewallet-jyB079Wb.js +20 -0
  72. package/dist/status-FrAvQjfn.js +4 -0
  73. package/dist/subwallet-DMvFqKyY.js +25 -0
  74. package/dist/talisman-Bp8zUXqB.js +16 -0
  75. package/dist/tallywallet-B4OS9nIr.js +16 -0
  76. package/dist/tokenary-C7jjcbQa.js +18 -0
  77. package/dist/tokenpocket-9ZRPmAFA.js +28 -0
  78. package/dist/tp-V2em5bdl.js +13 -0
  79. package/dist/transactionRequest-be6a8ea9-CUKWo5mx.js +1117 -0
  80. package/dist/trust-gPypS1O7.js +11 -0
  81. package/dist/xdefi-COVIyGz4.js +38 -0
  82. package/dist/zeal-DxHbDqm0.js +9 -0
  83. package/dist/zerion-BfW0UElc.js +8 -0
  84. package/dist/zodiacpilot-CrId6F4w.js +6 -0
  85. package/package.json +35 -15
  86. package/src/auth/config.ts +0 -2
  87. package/src/components/SignUp.tsx +442 -0
  88. package/src/components/forms/AgreementModal.tsx +88 -0
  89. package/src/components/forms/CaptchaController.tsx +94 -0
  90. package/src/components/forms/CaptchaModal.jsx +171 -0
  91. package/src/components/forms/CaptchaWidget.jsx +146 -0
  92. package/src/components/forms/PasswordChecker.ts +88 -0
  93. package/src/components/forms/SendCodeInput.tsx +149 -0
  94. package/src/components/forms/SignUpFormItem.tsx +704 -0
  95. package/src/components/forms/util/application-api.ts +155 -0
  96. package/src/components/forms/util/auth-api.ts +198 -0
  97. package/src/components/forms/util/auth-util.tsx +346 -0
  98. package/src/components/forms/util/core.ts +493 -0
  99. package/src/components/forms/util/invitation-api.ts +132 -0
  100. package/src/components/forms/util/provider.tsx +603 -0
  101. package/src/components/forms/util/user-api.ts +303 -0
  102. package/src/components/provider/AdfsLoginButton.jsx +38 -0
  103. package/src/components/provider/AlipayLoginButton.jsx +38 -0
  104. package/src/components/provider/AppleLoginButton.jsx +38 -0
  105. package/src/components/provider/AzureADB2CLoginButton.jsx +38 -0
  106. package/src/components/provider/AzureADLoginButton.jsx +38 -0
  107. package/src/components/provider/BaiduLoginButton.jsx +38 -0
  108. package/src/components/provider/BilibiliLoginButton.jsx +37 -0
  109. package/src/components/provider/CasdoorLoginButton.jsx +38 -0
  110. package/src/components/provider/DingTalkLoginButton.jsx +37 -0
  111. package/src/components/provider/DouyinLoginButton.jsx +38 -0
  112. package/src/components/provider/FacebookLoginButton.jsx +37 -0
  113. package/src/components/provider/GitHubLoginButton.jsx +37 -0
  114. package/src/components/provider/GitLabLoginButton.jsx +38 -0
  115. package/src/components/provider/GiteeLoginButton.jsx +34 -0
  116. package/src/components/provider/GoogleLoginButton.jsx +68 -0
  117. package/src/components/provider/InfoflowLoginButton.jsx +38 -0
  118. package/src/components/provider/LarkLoginButton.jsx +38 -0
  119. package/src/components/provider/LinkedInLoginButton.jsx +37 -0
  120. package/src/components/provider/LoginButton.jsx +33 -0
  121. package/src/components/provider/OktaLoginButton.jsx +38 -0
  122. package/src/components/provider/Provider.jsx +3 -0
  123. package/src/components/provider/ProviderButton.jsx +327 -0
  124. package/src/components/provider/QqLoginButton.jsx +31 -0
  125. package/src/components/provider/SelfLoginButton.jsx +47 -0
  126. package/src/components/provider/SlackLoginButton.jsx +38 -0
  127. package/src/components/provider/SteamLoginButton.jsx +38 -0
  128. package/src/components/provider/WeComLoginButton.jsx +34 -0
  129. package/src/components/provider/Web3Auth.jsx +365 -0
  130. package/src/components/provider/WechatLoginButton.jsx +37 -0
  131. package/src/components/provider/WeiboLoginButton.jsx +34 -0
  132. package/src/components/util.tsx +173 -0
  133. package/src/i18n/en/signup.json +48 -0
  134. package/src/i18n/index.ts +17 -0
  135. package/src/index.tsx +6 -1
  136. package/vite.config.ts +33 -25
@@ -0,0 +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
+ }