|
|
@@ -5,6 +5,7 @@ import ReactCardFlip from 'react-card-flip';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
+import { useCsrfToken } from '~/stores/context';
|
|
|
|
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
@@ -36,12 +37,12 @@ class LoginForm extends React.Component {
|
|
|
|
|
|
handleLoginWithExternalAuth(e) {
|
|
|
const auth = e.currentTarget.id;
|
|
|
- const { csrf } = this.props.appContainer;
|
|
|
- window.location.href = `/passport/${auth}?_csrf=${csrf}`;
|
|
|
+ const { csrfToken } = this.props;
|
|
|
+ window.location.href = `/passport/${auth}?_csrf=${csrfToken}`;
|
|
|
}
|
|
|
|
|
|
renderLocalOrLdapLoginForm() {
|
|
|
- const { t, appContainer, isLdapStrategySetup } = this.props;
|
|
|
+ const { t, csrfToken, isLdapStrategySetup } = this.props;
|
|
|
|
|
|
return (
|
|
|
<form role="form" action="/login" method="post">
|
|
|
@@ -71,7 +72,7 @@ class LoginForm extends React.Component {
|
|
|
</div>
|
|
|
|
|
|
<div className="input-group my-4">
|
|
|
- <input type="hidden" name="_csrf" value={appContainer.csrfToken} />
|
|
|
+ <input type="hidden" name="_csrf" value={csrfToken} />
|
|
|
<button type="submit" id="login" className="btn btn-fill rounded-0 login mx-auto" data-testid="btnSubmitForLogin">
|
|
|
<div className="eff"></div>
|
|
|
<span className="btn-label">
|
|
|
@@ -149,6 +150,7 @@ class LoginForm extends React.Component {
|
|
|
const {
|
|
|
t,
|
|
|
appContainer,
|
|
|
+ csrfToken,
|
|
|
isEmailAuthenticationEnabled,
|
|
|
username,
|
|
|
name,
|
|
|
@@ -252,7 +254,7 @@ class LoginForm extends React.Component {
|
|
|
)}
|
|
|
|
|
|
<div className="input-group justify-content-center my-4">
|
|
|
- <input type="hidden" name="_csrf" value={appContainer.csrfToken} />
|
|
|
+ <input type="hidden" name="_csrf" value={csrfToken} />
|
|
|
<button type="submit" className="btn btn-fill rounded-0" id="register" disabled={(!isMailerSetup && isEmailAuthenticationEnabled)}>
|
|
|
<div className="eff"></div>
|
|
|
<span className="btn-label">
|
|
|
@@ -333,6 +335,7 @@ LoginForm.propTypes = {
|
|
|
t: PropTypes.func.isRequired,
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
|
|
|
+ csrfToken: PropTypes.string,
|
|
|
isRegistering: PropTypes.bool,
|
|
|
username: PropTypes.string,
|
|
|
name: PropTypes.string,
|
|
|
@@ -349,7 +352,9 @@ LoginForm.propTypes = {
|
|
|
|
|
|
const LoginFormWrapperFC = (props) => {
|
|
|
const { t } = useTranslation();
|
|
|
- return <LoginForm t={t} {...props} />;
|
|
|
+ const { data: csrfToken } = useCsrfToken();
|
|
|
+
|
|
|
+ return <LoginForm t={t} csrfToken={csrfToken} {...props} />;
|
|
|
};
|
|
|
|
|
|
/**
|