2022-02-13 23:39:27 +08:00
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
2021-03-26 21:57:41 +08:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2022-07-10 15:45:55 +08:00
import React from "react" ;
2023-01-19 11:39:24 +01:00
import { Button , Form , Input , Result } from "antd" ;
2021-03-26 21:57:41 +08:00
import * as Setting from "../Setting" ;
import * as AuthBackend from "./AuthBackend" ;
2022-08-05 18:59:56 +08:00
import * as ProviderButton from "./ProviderButton" ;
2021-04-28 00:47:12 +08:00
import i18next from "i18next" ;
2021-04-28 15:54:50 +08:00
import * as Util from "./Util" ;
import { authConfig } from "./Auth" ;
import * as ApplicationBackend from "../backend/ApplicationBackend" ;
2023-02-12 18:56:56 +08:00
import { SendCodeInput } from "../common/SendCodeInput" ;
2021-07-31 16:02:48 +08:00
import SelectRegionBox from "../SelectRegionBox" ;
2021-11-06 22:04:20 +08:00
import CustomGithubCorner from "../CustomGithubCorner" ;
2022-10-03 22:40:19 +08:00
import SelectLanguageBox from "../SelectLanguageBox" ;
2022-11-13 05:16:49 +01:00
import { withRouter } from "react-router-dom" ;
2023-03-05 21:52:40 +08:00
import { CountryCodeSelect } from "../common/CountryCodeSelect" ;
2021-03-26 21:57:41 +08:00
const formItemLayout = {
labelCol : {
xs : {
span : 24 ,
} ,
sm : {
2021-07-31 16:02:48 +08:00
span : 8 ,
2021-03-26 21:57:41 +08:00
} ,
} ,
wrapperCol : {
xs : {
span : 24 ,
} ,
sm : {
2022-12-06 00:50:17 +08:00
span : 16 ,
2021-03-26 21:57:41 +08:00
} ,
} ,
} ;
const tailFormItemLayout = {
wrapperCol : {
xs : {
span : 24 ,
offset : 0 ,
} ,
sm : {
span : 16 ,
offset : 8 ,
} ,
} ,
} ;
2021-04-27 22:47:44 +08:00
class SignupPage extends React . Component {
2021-03-26 21:57:41 +08:00
constructor ( props ) {
super ( props ) ;
this . state = {
classes : props ,
2022-12-22 23:39:02 +08:00
applicationName : props . match . params ? . applicationName ? ? authConfig . appName ,
2021-04-28 15:54:50 +08:00
application : null ,
2021-05-18 20:11:03 +08:00
email : "" ,
2021-05-20 21:09:12 +08:00
phone : "" ,
2023-02-16 22:53:28 +08:00
countryCode : "" ,
2021-05-20 21:09:12 +08:00
emailCode : "" ,
2021-06-23 11:41:21 +08:00
phoneCode : "" ,
validEmail : false ,
validPhone : false ,
2021-07-31 16:02:48 +08:00
region : "" ,
2021-08-03 21:00:07 +08:00
isTermsOfUseVisible : false ,
2021-08-10 10:43:33 +08:00
termsOfUseContent : "" ,
2021-03-26 21:57:41 +08:00
} ;
this . form = React . createRef ( ) ;
}
2023-02-27 20:10:59 +08:00
componentDidMount ( ) {
2022-07-19 23:31:17 +08:00
let applicationName = this . state . applicationName ;
const oAuthParams = Util . getOAuthGetParameters ( ) ;
if ( oAuthParams !== null ) {
applicationName = oAuthParams . state ;
this . setState ( { applicationName : oAuthParams . state } ) ;
const signinUrl = window . location . href . replace ( "/signup/oauth/authorize" , "/login/oauth/authorize" ) ;
sessionStorage . setItem ( "signinUrl" , signinUrl ) ;
}
2022-12-22 23:39:02 +08:00
if ( this . getApplicationObj ( ) === null ) {
if ( applicationName !== undefined ) {
this . getApplication ( applicationName ) ;
} else {
Setting . showMessage ( "error" , ` Unknown application name: ${ applicationName } ` ) ;
}
2021-04-28 15:54:50 +08:00
}
}
2022-07-19 23:31:17 +08:00
getApplication ( applicationName ) {
if ( applicationName === undefined ) {
2021-04-28 15:54:50 +08:00
return ;
}
2022-07-19 23:31:17 +08:00
ApplicationBackend . getApplication ( "admin" , applicationName )
2021-04-28 15:54:50 +08:00
. then ( ( application ) => {
2022-12-22 23:39:02 +08:00
this . onUpdateApplication ( application ) ;
2021-04-28 15:54:50 +08:00
this . setState ( {
application : application ,
} ) ;
2022-06-26 09:34:01 +08:00
if ( application !== null && application !== undefined ) {
2023-01-19 11:39:24 +01:00
Setting . getTermsOfUseContent ( application . termsOfUse , res => {
this . setState ( { termsOfUseContent : res } ) ;
} ) ;
2022-06-26 09:34:01 +08:00
}
2021-04-28 15:54:50 +08:00
} ) ;
}
2021-04-28 22:40:21 +08:00
getResultPath ( application ) {
if ( authConfig . appName === application . name ) {
return "/result" ;
} else {
2021-06-20 09:46:06 +08:00
if ( Setting . hasPromptPage ( application ) ) {
return ` /prompt/ ${ application . name } ` ;
} else {
return ` /result/ ${ application . name } ` ;
}
2021-04-28 22:40:21 +08:00
}
}
2021-06-14 13:13:39 +08:00
getApplicationObj ( ) {
2022-12-22 23:39:02 +08:00
return this . props . application ? ? this . state . application ;
2021-06-14 13:13:39 +08:00
}
2021-06-20 13:27:26 +08:00
onUpdateAccount ( account ) {
this . props . onUpdateAccount ( account ) ;
}
2022-12-22 23:39:02 +08:00
onUpdateApplication ( application ) {
this . props . onUpdateApplication ( application ) ;
}
2022-10-22 21:43:41 +08:00
parseOffset ( offset ) {
if ( offset === 2 || offset === 4 || Setting . inIframe ( ) || Setting . isMobile ( ) ) {
return "0 auto" ;
}
if ( offset === 1 ) {
return "0 10%" ;
}
if ( offset === 3 ) {
return "0 60%" ;
}
}
2021-03-26 21:57:41 +08:00
onFinish ( values ) {
2021-06-14 13:13:39 +08:00
const application = this . getApplicationObj ( ) ;
2021-04-27 22:47:44 +08:00
AuthBackend . signup ( values )
2021-03-26 21:57:41 +08:00
. then ( ( res ) => {
2022-07-10 15:45:55 +08:00
if ( res . status === "ok" ) {
2021-08-01 00:16:13 +08:00
if ( Setting . hasPromptPage ( application ) ) {
AuthBackend . getAccount ( "" )
. then ( ( res ) => {
let account = null ;
if ( res . status === "ok" ) {
account = res . data ;
account . organization = res . data2 ;
this . onUpdateAccount ( account ) ;
Setting . goToLinkSoft ( this , this . getResultPath ( application ) ) ;
} else {
2021-06-20 13:27:26 +08:00
Setting . showMessage ( "error" , ` Failed to sign in: ${ res . msg } ` ) ;
}
2021-08-01 00:16:13 +08:00
} ) ;
} else {
Setting . goToLinkSoft ( this , this . getResultPath ( application ) ) ;
}
2021-03-26 21:57:41 +08:00
} else {
2021-05-18 20:11:03 +08:00
Setting . showMessage ( "error" , i18next . t ( ` signup: ${ res . msg } ` ) ) ;
2021-03-26 21:57:41 +08:00
}
} ) ;
}
onFinishFailed ( values , errorFields , outOfDate ) {
this . form . current . scrollToField ( errorFields [ 0 ] . name ) ;
}
2022-08-05 18:59:56 +08:00
isProviderVisible ( providerItem ) {
if ( this . state . mode === "signup" ) {
return Setting . isProviderVisibleForSignUp ( providerItem ) ;
} else {
return Setting . isProviderVisibleForSignIn ( providerItem ) ;
}
}
2021-06-16 14:06:41 +08:00
renderFormItem ( application , signupItem ) {
if ( ! signupItem . visible ) {
return null ;
2021-05-08 00:23:08 +08:00
}
2021-06-16 15:25:54 +08:00
const required = signupItem . required ;
2021-06-16 14:06:41 +08:00
if ( signupItem . name === "Username" ) {
return (
2021-03-26 21:57:41 +08:00
< Form . Item
2021-04-28 00:47:12 +08:00
name = "username"
label = { i18next . t ( "signup:Username" ) }
2021-03-26 21:57:41 +08:00
rules = { [
{
2021-06-16 15:25:54 +08:00
required : required ,
2021-06-17 22:43:30 +08:00
message : i18next . t ( "forget:Please input your username!" ) ,
2021-03-26 21:57:41 +08:00
whitespace : true ,
} ,
] }
>
< Input / >
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
} else if ( signupItem . name === "Display name" ) {
2022-02-27 14:02:52 +08:00
if ( signupItem . rule === "First, last" && Setting . getLanguage ( ) !== "zh" ) {
return (
< React . Fragment >
< Form . Item
name = "firstName"
label = { i18next . t ( "general:First name" ) }
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please input your first name!" ) ,
whitespace : true ,
} ,
] }
>
< Input / >
< / F o r m . I t e m >
< Form . Item
name = "lastName"
label = { i18next . t ( "general:Last name" ) }
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please input your last name!" ) ,
whitespace : true ,
} ,
] }
>
< Input / >
< / F o r m . I t e m >
< / R e a c t . F r a g m e n t >
2022-07-10 15:45:55 +08:00
) ;
2022-02-27 14:02:52 +08:00
}
2021-06-16 14:06:41 +08:00
return (
2021-03-26 21:57:41 +08:00
< Form . Item
2021-04-28 21:25:58 +08:00
name = "name"
2022-02-27 14:02:52 +08:00
label = { ( signupItem . rule === "Real name" || signupItem . rule === "First, last" ) ? i18next . t ( "general:Real name" ) : i18next . t ( "general:Display name" ) }
2021-03-26 21:57:41 +08:00
rules = { [
{
2021-06-16 15:25:54 +08:00
required : required ,
2022-02-27 14:02:52 +08:00
message : ( signupItem . rule === "Real name" || signupItem . rule === "First, last" ) ? i18next . t ( "signup:Please input your real name!" ) : i18next . t ( "signup:Please input your display name!" ) ,
2021-03-26 21:57:41 +08:00
whitespace : true ,
} ,
] }
>
< Input / >
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
} else if ( signupItem . name === "Affiliation" ) {
return (
2021-03-26 21:57:41 +08:00
< Form . Item
2021-04-27 22:35:14 +08:00
name = "affiliation"
2021-04-28 00:47:12 +08:00
label = { i18next . t ( "user:Affiliation" ) }
2021-03-26 21:57:41 +08:00
rules = { [
{
2021-06-16 15:25:54 +08:00
required : required ,
2021-04-28 00:47:12 +08:00
message : i18next . t ( "signup:Please input your affiliation!" ) ,
2021-03-26 21:57:41 +08:00
whitespace : true ,
} ,
] }
>
< Input / >
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-12-28 17:48:24 +08:00
} else if ( signupItem . name === "ID card" ) {
return (
< Form . Item
name = "idCard"
label = { i18next . t ( "user:ID card" ) }
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please input your ID card number!" ) ,
whitespace : true ,
} ,
{
required : required ,
pattern : new RegExp ( /^[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]$/ , "g" ) ,
message : i18next . t ( "signup:Please input the correct ID card number!" ) ,
} ,
] }
>
< Input / >
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-07-31 16:02:48 +08:00
} else if ( signupItem . name === "Country/Region" ) {
return (
< Form . Item
2022-07-10 15:45:55 +08:00
name = "country_region"
label = { i18next . t ( "user:Country/Region" ) }
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please select your country/region!" ) ,
} ,
] }
2021-07-31 16:02:48 +08:00
>
2022-07-10 15:45:55 +08:00
< SelectRegionBox onChange = { ( value ) => { this . setState ( { region : value } ) ; } } / >
2021-07-31 16:02:48 +08:00
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
} else if ( signupItem . name === "Email" ) {
return (
< React . Fragment >
< Form . Item
name = "email"
label = { i18next . t ( "general:Email" ) }
rules = { [
{
2021-06-16 15:25:54 +08:00
required : required ,
2021-06-16 14:06:41 +08:00
message : i18next . t ( "signup:Please input your Email!" ) ,
} ,
2021-06-23 11:41:21 +08:00
{
2021-09-21 14:04:17 +08:00
validator : ( _ , value ) => {
if ( this . state . email !== "" && ! Setting . isValidEmail ( this . state . email ) ) {
this . setState ( { validEmail : false } ) ;
return Promise . reject ( i18next . t ( "signup:The input is not valid Email!" ) ) ;
2021-06-23 11:41:21 +08:00
}
2021-09-21 14:04:17 +08:00
this . setState ( { validEmail : true } ) ;
return Promise . resolve ( ) ;
2022-08-06 23:54:56 +08:00
} ,
} ,
2021-06-16 14:06:41 +08:00
] }
>
< Input onChange = { e => this . setState ( { email : e . target . value } ) } / >
< / F o r m . I t e m >
2022-05-02 17:19:40 +08:00
{
2022-07-10 15:45:55 +08:00
signupItem . rule !== "No verification" &&
2022-05-02 17:19:40 +08:00
< Form . Item
name = "emailCode"
label = { i18next . t ( "code:Email code" ) }
rules = { [ {
required : required ,
message : i18next . t ( "code:Please input your verification code!" ) ,
} ] }
>
2023-02-12 18:56:56 +08:00
< SendCodeInput
2022-05-02 17:19:40 +08:00
disabled = { ! this . state . validEmail }
2022-12-11 15:52:36 +08:00
method = { "signup" }
2022-07-10 00:40:52 +08:00
onButtonClickArgs = { [ this . state . email , "email" , Setting . getApplicationName ( application ) ] }
2022-08-23 23:30:45 +08:00
application = { application }
2022-05-02 17:19:40 +08:00
/ >
< / F o r m . I t e m >
}
2021-06-16 14:06:41 +08:00
< / R e a c t . F r a g m e n t >
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
} else if ( signupItem . name === "Phone" ) {
return (
< React . Fragment >
2023-03-15 23:44:38 +08:00
< Form . Item label = { i18next . t ( "general:Phone" ) } required = { required } >
2023-02-16 22:53:28 +08:00
< Input . Group compact >
< Form . Item
name = "countryCode"
noStyle
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please select your country code!" ) ,
} ,
] }
>
2023-03-05 21:52:40 +08:00
< CountryCodeSelect
2023-02-16 22:53:28 +08:00
style = { { width : "35%" } }
countryCodes = { this . getApplicationObj ( ) . organizationObj . countryCodes }
/ >
< / F o r m . I t e m >
< Form . Item
name = "phone"
2023-02-27 22:07:28 +08:00
dependencies = { [ "countryCode" ] }
2023-02-16 22:53:28 +08:00
noStyle
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please input your phone number!" ) ,
} ,
2023-02-27 22:07:28 +08:00
( { getFieldValue } ) => ( {
2023-02-16 22:53:28 +08:00
validator : ( _ , value ) => {
2023-03-15 23:44:38 +08:00
if ( ! required && value === "" ) {
return Promise . resolve ( ) ;
}
2023-02-27 22:07:28 +08:00
if ( value !== "" && ! Setting . isValidPhone ( value , getFieldValue ( "countryCode" ) ) ) {
2023-02-16 22:53:28 +08:00
this . setState ( { validPhone : false } ) ;
return Promise . reject ( i18next . t ( "signup:The input is not valid Phone!" ) ) ;
}
this . setState ( { validPhone : true } ) ;
return Promise . resolve ( ) ;
} ,
2023-02-27 22:07:28 +08:00
} ) ,
2023-02-16 22:53:28 +08:00
] }
>
< Input
style = { { width : "65%" } }
onChange = { e => this . setState ( { phone : e . target . value } ) }
/ >
< / F o r m . I t e m >
< / I n p u t . G r o u p >
2021-06-16 14:06:41 +08:00
< / F o r m . I t e m >
< Form . Item
name = "phoneCode"
2021-06-17 22:43:30 +08:00
label = { i18next . t ( "code:Phone code" ) }
2021-06-16 14:06:41 +08:00
rules = { [
{
2021-06-16 15:25:54 +08:00
required : required ,
2021-06-17 22:43:30 +08:00
message : i18next . t ( "code:Please input your phone verification code!" ) ,
2021-06-16 14:06:41 +08:00
} ,
] }
>
2023-02-12 18:56:56 +08:00
< SendCodeInput
2021-06-23 11:41:21 +08:00
disabled = { ! this . state . validPhone }
2022-12-11 15:52:36 +08:00
method = { "signup" }
2022-07-10 00:40:52 +08:00
onButtonClickArgs = { [ this . state . phone , "phone" , Setting . getApplicationName ( application ) ] }
2022-08-23 23:30:45 +08:00
application = { application }
2023-03-05 21:52:40 +08:00
countryCode = { this . form . current ? . getFieldValue ( "countryCode" ) }
2021-06-16 14:06:41 +08:00
/ >
< / F o r m . I t e m >
< / R e a c t . F r a g m e n t >
2022-07-10 15:45:55 +08:00
) ;
2021-09-21 14:04:17 +08:00
} else if ( signupItem . name === "Password" ) {
return (
< Form . Item
name = "password"
label = { i18next . t ( "general:Password" ) }
rules = { [
{
required : required ,
2021-12-06 09:38:22 +08:00
min : 6 ,
message : i18next . t ( "login:Please input your password, at least 6 characters!" ) ,
2021-09-21 14:04:17 +08:00
} ,
] }
hasFeedback
>
< Input . Password / >
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-09-21 14:04:17 +08:00
} else if ( signupItem . name === "Confirm password" ) {
return (
< Form . Item
name = "confirm"
label = { i18next . t ( "signup:Confirm" ) }
2022-07-10 15:45:55 +08:00
dependencies = { [ "password" ] }
2021-09-21 14:04:17 +08:00
hasFeedback
rules = { [
{
required : required ,
message : i18next . t ( "signup:Please confirm your password!" ) ,
} ,
2022-07-10 15:45:55 +08:00
( { getFieldValue } ) => ( {
2021-09-21 14:04:17 +08:00
validator ( rule , value ) {
2022-07-10 15:45:55 +08:00
if ( ! value || getFieldValue ( "password" ) === value ) {
2021-09-21 14:04:17 +08:00
return Promise . resolve ( ) ;
}
return Promise . reject ( i18next . t ( "signup:Your confirmed password is inconsistent with the password!" ) ) ;
} ,
} ) ,
] }
>
< Input . Password / >
< / F o r m . I t e m >
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
} else if ( signupItem . name === "Agreement" ) {
return (
2023-01-19 11:39:24 +01:00
Setting . renderAgreement ( Setting . isAgreementRequired ( application ) , ( ) => {
this . setState ( {
isTermsOfUseVisible : true ,
} ) ;
2023-01-19 13:31:21 +01:00
} , false , tailFormItemLayout , Setting . isDefaultTrue ( application ) )
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
}
}
2021-03-26 21:57:41 +08:00
2021-08-03 21:00:07 +08:00
renderModal ( ) {
return (
2023-01-19 11:39:24 +01:00
Setting . renderModal ( this . state . isTermsOfUseVisible , ( ) => {
this . form . current . setFieldsValue ( { agreement : true } ) ;
this . setState ( {
isTermsOfUseVisible : false ,
} ) ;
} , ( ) => {
this . form . current . setFieldsValue ( { agreement : false } ) ;
this . setState ( {
isTermsOfUseVisible : false ,
} ) ;
} , this . state . termsOfUseContent )
2022-07-10 15:45:55 +08:00
) ;
2021-08-03 21:00:07 +08:00
}
2021-06-16 14:06:41 +08:00
renderForm ( application ) {
if ( ! application . enableSignUp ) {
return (
< Result
status = "error"
2022-11-27 14:04:45 +01:00
title = { i18next . t ( "application:Sign Up Error" ) }
subTitle = { i18next . t ( "application:The application does not allow to sign up new account" ) }
2021-06-16 14:06:41 +08:00
extra = { [
2022-11-13 05:16:49 +01:00
< Button type = "primary" key = "signin" onClick = { ( ) => Setting . redirectToLoginPage ( application , this . props . history ) } >
2022-10-27 20:23:57 +02:00
{
i18next . t ( "login:Sign In" )
}
2022-08-06 23:54:56 +08:00
< / B u t t o n > ,
2021-03-26 21:57:41 +08:00
] }
>
2021-06-16 14:06:41 +08:00
< / R e s u l t >
2022-07-10 15:45:55 +08:00
) ;
2021-06-16 14:06:41 +08:00
}
return (
< Form
{ ... formItemLayout }
ref = { this . form }
name = "signup"
onFinish = { ( values ) => this . onFinish ( values ) }
onFinishFailed = { ( errorInfo ) => this . onFinishFailed ( errorInfo . values , errorInfo . errorFields , errorInfo . outOfDate ) }
initialValues = { {
application : application . name ,
organization : application . organization ,
2023-02-27 22:07:28 +08:00
countryCode : application . organizationObj . countryCodes ? . [ 0 ] ,
2021-06-16 14:06:41 +08:00
} }
size = "large"
2022-12-06 00:50:17 +08:00
layout = { Setting . isMobile ( ) ? "vertical" : "horizontal" }
style = { { width : Setting . isMobile ( ) ? "300px" : "400px" } }
2021-06-16 14:06:41 +08:00
>
2021-03-26 21:57:41 +08:00
< Form . Item
2021-06-16 14:06:41 +08:00
name = "application"
2022-12-06 00:50:17 +08:00
hidden = { true }
2021-03-26 21:57:41 +08:00
rules = { [
{
required : true ,
2022-07-10 15:45:55 +08:00
message : "Please input your application!" ,
2021-03-26 21:57:41 +08:00
} ,
] }
>
< / F o r m . I t e m >
2021-05-18 20:11:03 +08:00
< Form . Item
2021-06-16 14:06:41 +08:00
name = "organization"
2022-12-06 00:50:17 +08:00
hidden = { true }
2021-05-18 20:11:03 +08:00
rules = { [
{
required : true ,
2022-07-10 15:45:55 +08:00
message : "Please input your organization!" ,
2021-05-18 20:11:03 +08:00
} ,
] }
>
2021-03-26 21:57:41 +08:00
< / F o r m . I t e m >
2021-06-16 14:06:41 +08:00
{
2021-06-22 11:31:53 +08:00
application . signupItems ? . map ( signupItem => this . renderFormItem ( application , signupItem ) )
2021-06-16 14:06:41 +08:00
}
2021-03-26 21:57:41 +08:00
< Form . Item { ... tailFormItemLayout } >
< Button type = "primary" htmlType = "submit" >
2021-04-28 00:47:12 +08:00
{ i18next . t ( "account:Sign Up" ) }
2021-03-26 21:57:41 +08:00
< / B u t t o n >
2022-12-06 00:50:17 +08:00
& nbsp ; & nbsp ; { i18next . t ( "signup:Have account?" ) } & nbsp ;
2022-06-17 19:57:11 +08:00
< a onClick = { ( ) => {
2022-08-08 23:35:24 +08:00
const linkInStorage = sessionStorage . getItem ( "signinUrl" ) ;
2022-09-04 19:40:30 +08:00
if ( linkInStorage !== null && linkInStorage !== "" ) {
2022-07-10 15:45:55 +08:00
Setting . goToLink ( linkInStorage ) ;
2022-09-04 19:40:30 +08:00
} else {
2022-11-13 05:16:49 +01:00
Setting . redirectToLoginPage ( application , this . props . history ) ;
2022-03-05 16:47:08 +08:00
}
2021-04-28 22:40:21 +08:00
} } >
2021-04-28 00:47:12 +08:00
{ i18next . t ( "signup:sign in now" ) }
2021-07-16 17:04:16 +08:00
< / a >
2021-03-26 21:57:41 +08:00
< / F o r m . I t e m >
2022-08-05 18:59:56 +08:00
{
application . providers . filter ( providerItem => this . isProviderVisible ( providerItem ) ) . map ( providerItem => {
2022-09-28 21:09:39 +08:00
return ProviderButton . renderProviderLogo ( providerItem . provider , application , 30 , 5 , "small" , this . props . location ) ;
2022-08-05 18:59:56 +08:00
} )
}
2021-03-26 21:57:41 +08:00
< / F o r m >
2022-07-10 15:45:55 +08:00
) ;
2021-03-26 21:57:41 +08:00
}
render ( ) {
2021-06-14 13:13:39 +08:00
const application = this . getApplicationObj ( ) ;
2021-04-28 15:54:50 +08:00
if ( application === null ) {
return null ;
}
2021-10-26 13:11:21 +08:00
if ( application . signupHtml !== "" ) {
return (
2022-07-10 15:45:55 +08:00
< div dangerouslySetInnerHTML = { { _ _html : application . signupHtml } } / >
) ;
2021-10-26 13:11:21 +08:00
}
2021-03-26 21:57:41 +08:00
return (
2022-12-22 23:39:02 +08:00
< React . Fragment >
2021-11-06 22:04:20 +08:00
< CustomGithubCorner / >
2022-12-24 17:47:05 +08:00
< div className = "login-content" style = { { margin : this . props . preview ? ? this . parseOffset ( application . formOffset ) } } >
2022-12-04 15:53:46 +08:00
{ Setting . inIframe ( ) || Setting . isMobile ( ) ? null : < div dangerouslySetInnerHTML = { { _ _html : application . formCss } } / > }
2022-10-22 21:43:41 +08:00
< div className = "login-panel" >
< div className = "side-image" style = { { display : application . formOffset !== 4 ? "none" : null } } >
< div dangerouslySetInnerHTML = { { _ _html : application . formSideHtml } } / >
< / d i v >
< div className = "login-form" >
2022-12-06 00:50:17 +08:00
{
Setting . renderHelmet ( application )
}
{
Setting . renderLogo ( application )
}
< SelectLanguageBox languages = { application . organizationObj . languages } style = { { top : "55px" , right : "5px" , position : "absolute" } } / >
{
this . renderForm ( application )
}
2021-04-28 15:54:50 +08:00
< / d i v >
2022-10-22 21:43:41 +08:00
< / d i v >
< / d i v >
2021-08-03 21:00:07 +08:00
{
this . renderModal ( )
}
2022-12-22 23:39:02 +08:00
< / R e a c t . F r a g m e n t >
2022-07-10 15:45:55 +08:00
) ;
2021-03-26 21:57:41 +08:00
}
}
2022-11-13 05:16:49 +01:00
export default withRouter ( SignupPage ) ;