From f7064f3baa6e068ea639afc1c9f2e3b85ff3f59d Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Wed, 30 Sep 2020 21:20:51 +0300 Subject: [PATCH] Web: Common: login: added hashPassword --- web/ASC.Web.Common/src/api/user/index.js | 7 +- web/ASC.Web.Common/src/pages/login/index.js | 141 ++++++++++--------- web/ASC.Web.Common/src/store/auth/actions.js | 38 ++--- 3 files changed, 95 insertions(+), 91 deletions(-) diff --git a/web/ASC.Web.Common/src/api/user/index.js b/web/ASC.Web.Common/src/api/user/index.js index 616be75267..72455af8ed 100644 --- a/web/ASC.Web.Common/src/api/user/index.js +++ b/web/ASC.Web.Common/src/api/user/index.js @@ -1,10 +1,9 @@ - import { request, setAuthorizationToken } from "../client"; -export function login(userName, password) { +export function login(userName, hash) { const data = { userName, - password + passwordHash: hash }; return request({ @@ -33,4 +32,4 @@ export function checkConfirmLink(data) { url: "/authentication/confirm.json", data }); -} \ No newline at end of file +} diff --git a/web/ASC.Web.Common/src/pages/login/index.js b/web/ASC.Web.Common/src/pages/login/index.js index c544b181f7..e84e6a4f07 100644 --- a/web/ASC.Web.Common/src/pages/login/index.js +++ b/web/ASC.Web.Common/src/pages/login/index.js @@ -22,6 +22,7 @@ import ForgotPasswordModalDialog from "./sub-components/forgot-password-modal-di import { login, setIsLoaded } from "../../store/auth/actions"; import { sendInstructionsToChangePassword } from "../../api/people"; import Register from "./sub-components/register-container"; +import { createHashPassword } from "../../utils"; const LoginContainer = styled.div` display: flex; @@ -33,11 +34,11 @@ const LoginContainer = styled.div` @media (max-width: 768px) { padding: 0 16px; max-width: 475px; - } + } @media (max-width: 375px) { margin: 72px auto 0 auto; max-width: 311px; - } + } .greeting-title { width: 100%; @@ -56,11 +57,11 @@ const LoginContainer = styled.div` @media (max-width: 768px) { margin: 32px 0 0 0; - width: 100% + width: 100%; } @media (max-width: 375px) { margin: 32px 0 0 0; - width: 100% + width: 100%; } .login-forgot-wrapper { @@ -73,48 +74,48 @@ const LoginContainer = styled.div` .login-checkbox { float: left; - span { + span { font-size: 12px; - } - } + } + } - .login-tooltip { - display: inline-flex; + .login-tooltip { + display: inline-flex; - @media(min-width: 1025px) { - margin-left: 8px; - margin-top: 4px; - } - @media(max-width: 1024px) { - padding: 4px 8px 8px 8px; - } + @media (min-width: 1025px) { + margin-left: 8px; + margin-top: 4px; + } + @media (max-width: 1024px) { + padding: 4px 8px 8px 8px; + } + } } - } .login-link { float: right; line-height: 16px; } - } + } - .login-button { - margin-bottom: 16px; - } + .login-button { + margin-bottom: 16px; + } - .login-button-dialog { - margin-right: 8px; - } + .login-button-dialog { + margin-right: 8px; + } - .login-bottom-border { - width: 100%; - height: 1px; - background: #ECEEF1; - } + .login-bottom-border { + width: 100%; + height: 1px; + background: #eceef1; + } - .login-bottom-text { - margin: 0 8px; + .login-bottom-text { + margin: 0 8px; + } } -} `; class Form extends Component { @@ -174,8 +175,7 @@ class Form extends Component { onSendPasswordInstructions = () => { if (!this.state.email.trim()) { this.setState({ emailError: true }); - } - else { + } else { this.setState({ isLoading: true }); sendInstructionsToChangePassword(this.state.email) .then( @@ -198,7 +198,7 @@ class Form extends Component { onSubmit = () => { const { errorText, identifier, password } = this.state; - const { login, setIsLoaded, history } = this.props; + const { login, setIsLoaded, history, passwordHash } = this.props; errorText && this.setState({ errorText: "" }); let hasError = false; @@ -221,7 +221,9 @@ class Form extends Component { this.setState({ isLoading: true }); - login(userName, pass) + const hash = createHashPassword(pass, passwordHash); + + login(userName, hash) .then(() => { setIsLoaded(true); history.push("/"); @@ -231,7 +233,7 @@ class Form extends Component { }); }; - componentDidMount() { + async componentDidMount() { const { match, t } = this.props; const { error, confirmedEmail } = match.params; @@ -251,7 +253,7 @@ class Form extends Component { upperCase: false, digits: false, specSymbols: false - } + }; render() { const { greetingTitle, match, t } = this.props; @@ -276,16 +278,16 @@ class Form extends Component { return ( <> - - + className="greeting-title" + > {greetingTitle}
- {t("Remember")}} + label={{t("Remember")}} /> {t("RememberHelper")} + {t("RememberHelper")} } /> - {openDialog && + {openDialog && ( - } + )}