From 4932f6aef0ac41fb52b377640505643b0940078f Mon Sep 17 00:00:00 2001 From: Andrii Podriez Date: Wed, 31 Jul 2024 17:03:47 +0200 Subject: [PATCH] added forgot password message to the login page Signed-off-by: Andrii Podriez --- src/pages/login/login-form.js | 18 +++++++------ src/pages/login/login.js | 3 ++- src/pages/login/recover-password.js | 40 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 src/pages/login/recover-password.js diff --git a/src/pages/login/login-form.js b/src/pages/login/login-form.js index 26dbc1e..d4cca3b 100644 --- a/src/pages/login/login-form.js +++ b/src/pages/login/login-form.js @@ -20,8 +20,10 @@ import { Form, Button, Col } from 'react-bootstrap'; import { useDispatch } from 'react-redux'; import { login } from '../../store/userSlice'; import _ from 'lodash'; +import { sessionToken } from '../../localStorage'; +import RecoverPassword from './recover-password'; -const LoginForm = (props) => { +const LoginForm = ({loginMessage, config}) => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [forgottenPassword, setForgottenPassword] = useState(false) @@ -66,10 +68,10 @@ const LoginForm = (props) => { - {props.loginMessage && + {loginMessage &&
- Error: {props.loginMessage} + Error: {loginMessage}
} @@ -83,14 +85,14 @@ const LoginForm = (props) => { - {/* setForgottenPassword(false)} sessionToken={props.sessionToken} /> */} + setForgottenPassword(false)} config={config} /> ); - if (props.config) { - let externalLogin = _.get(props.config, ['authentication', 'external', 'enabled']) - let provider = _.get(props.config, ['authentication', 'external', 'provider_name']) - let url = _.get(props.config, ['authentication', 'external', 'authorize_url']) + "?rd=/login/complete" + if (config) { + let externalLogin = _.get(config, ['authentication', 'external', 'enabled']) + let provider = _.get(config, ['authentication', 'external', 'provider_name']) + let url = _.get(config, ['authentication', 'external', 'authorize_url']) + "?rd=/login/complete" if (externalLogin && provider && url) { return [ diff --git a/src/pages/login/login.js b/src/pages/login/login.js index 3a202b6..5190136 100644 --- a/src/pages/login/login.js +++ b/src/pages/login/login.js @@ -24,6 +24,7 @@ import LoginForm from './login-form'; import Header from '../../common/header'; import NotificationsDataManager from '../../common/data-managers/notifications-data-manager'; import branding from '../../branding/branding'; +import { useGetConfigQuery } from '../../store/apiSlice'; const Login = (props) => { @@ -33,7 +34,7 @@ const Login = (props) => { NotificationsDataManager.setSystem(notificationSystem); }, []); - const config = null + const {data: config} = useGetConfigQuery(); const currentUser = useSelector(state => state.user.currentUser); const loginMessage = useSelector(state => state.user.loginMessage); diff --git a/src/pages/login/recover-password.js b/src/pages/login/recover-password.js new file mode 100644 index 0000000..a8f958e --- /dev/null +++ b/src/pages/login/recover-password.js @@ -0,0 +1,40 @@ +/** + * This file is part of VILLASweb. + * + * VILLASweb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VILLASweb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with VILLASweb. If not, see . + ******************************************************************************/ + +import Dialog from "../../common/dialogs/dialog"; +import _ from 'lodash'; + +const RecoverPassword = ({show, onClose, config}) => { + return ( + onClose(c)} + blendOutCancel={true} + valid={true} + > +
+
Please contact:
+
{_.get(config, ['contact', 'name'])}
+ {_.get(config, ['contact', 'mail'])} +
+
+ ) +} + +export default RecoverPassword; \ No newline at end of file