|
@@ -1,13 +1,14 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
-
|
|
|
|
|
|
|
+import loggerFactory from '@alias/logger';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
-import AppContainer from '../services/AppContainer';
|
|
|
|
|
|
|
+import LoginContainer from '../services/LoginContainer';
|
|
|
import { createSubscribedElement } from './UnstatedUtils';
|
|
import { createSubscribedElement } from './UnstatedUtils';
|
|
|
|
|
|
|
|
-class LoginForm extends React.Component {
|
|
|
|
|
|
|
+const logger = loggerFactory('growi:loginForm');
|
|
|
|
|
|
|
|
|
|
+class LoginForm extends React.Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
|
|
|
|
@@ -25,30 +26,22 @@ class LoginForm extends React.Component {
|
|
|
this.renderRegisterForm = this.renderRegisterForm.bind(this);
|
|
this.renderRegisterForm = this.renderRegisterForm.bind(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- componentWillMount() {
|
|
|
|
|
- // [TODO][GW-1913] get params from server with axios
|
|
|
|
|
- this.isRegistrationEnabled = true;
|
|
|
|
|
- this.registrationMode = 'Open';
|
|
|
|
|
- this.registrationWhiteList = [];
|
|
|
|
|
- this.isLocalStrategySetup = true;
|
|
|
|
|
- this.isLdapStrategySetup = true;
|
|
|
|
|
- this.objOfIsExternalAuthEnableds = {
|
|
|
|
|
- google: true,
|
|
|
|
|
- github: true,
|
|
|
|
|
- facebook: true,
|
|
|
|
|
- twitter: true,
|
|
|
|
|
- oidc: true,
|
|
|
|
|
- saml: true,
|
|
|
|
|
- basic: true,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ async componentDidMount() {
|
|
|
|
|
+ const { loginContainer } = this.props;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ await loginContainer.retrieveData();
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ loginContainer.setState({ retrieveError: err.message });
|
|
|
|
|
+ logger.error(err);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// for flip [TODO][GW-1865] use state or react component for flip
|
|
// for flip [TODO][GW-1865] use state or react component for flip
|
|
|
switchForm(e) {
|
|
switchForm(e) {
|
|
|
if (e.target.id === 'register') {
|
|
if (e.target.id === 'register') {
|
|
|
$('#login-dialog').addClass('to-flip');
|
|
$('#login-dialog').addClass('to-flip');
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ } else {
|
|
|
$('#login-dialog').removeClass('to-flip');
|
|
$('#login-dialog').removeClass('to-flip');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -129,7 +122,7 @@ class LoginForm extends React.Component {
|
|
|
<div id="external-auth" className={`external-auth ${collapsibleClass}`}>
|
|
<div id="external-auth" className={`external-auth ${collapsibleClass}`}>
|
|
|
<div className="spacer"></div>
|
|
<div className="spacer"></div>
|
|
|
<div className="d-flex flex-row justify-content-between flex-wrap">
|
|
<div className="d-flex flex-row justify-content-between flex-wrap">
|
|
|
- {Object.keys(this.objOfIsExternalAuthEnableds).map((auth) => {
|
|
|
|
|
|
|
+ {Object.keys(this.objOfIsExternalAuthEnableds).map(auth => {
|
|
|
if (!this.objOfIsExternalAuthEnableds[auth]) {
|
|
if (!this.objOfIsExternalAuthEnableds[auth]) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -201,7 +194,7 @@ class LoginForm extends React.Component {
|
|
|
<>
|
|
<>
|
|
|
<p className="form-text">{t('page_register.form_help.email')}</p>
|
|
<p className="form-text">{t('page_register.form_help.email')}</p>
|
|
|
<ul>
|
|
<ul>
|
|
|
- {this.registrationWhiteList.map((elem) => {
|
|
|
|
|
|
|
+ {this.registrationWhiteList.map(elem => {
|
|
|
return (
|
|
return (
|
|
|
<li>
|
|
<li>
|
|
|
<code>{{ elem }}</code>
|
|
<code>{{ elem }}</code>
|
|
@@ -281,19 +274,19 @@ class LoginForm extends React.Component {
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Wrapper component for using unstated
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
*/
|
|
|
const LoginFormWrapper = (props) => {
|
|
const LoginFormWrapper = (props) => {
|
|
|
- return createSubscribedElement(LoginForm, props, [AppContainer]);
|
|
|
|
|
|
|
+ return createSubscribedElement(LoginForm, props, [LoginContainer]);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
LoginForm.propTypes = {
|
|
LoginForm.propTypes = {
|
|
|
// i18next
|
|
// i18next
|
|
|
t: PropTypes.func.isRequired,
|
|
t: PropTypes.func.isRequired,
|
|
|
|
|
+ loginContainer: PropTypes.instanceOf(LoginContainer).isRequired,
|
|
|
isRegistering: PropTypes.bool,
|
|
isRegistering: PropTypes.bool,
|
|
|
username: PropTypes.string,
|
|
username: PropTypes.string,
|
|
|
name: PropTypes.string,
|
|
name: PropTypes.string,
|