1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

load config from login

This commit is contained in:
irismarie 2021-02-17 18:19:26 +01:00
parent 83674086f4
commit 2b7a5fe81f
2 changed files with 8 additions and 6 deletions

View file

@ -48,11 +48,6 @@ class App extends React.Component {
this.state = {
showSidebarMenu: false,
}
// load config from backend
AppDispatcher.dispatch({
type: 'config/load',
});
}
componentDidMount() {

View file

@ -26,6 +26,7 @@ import Header from '../common/header';
import Footer from '../common/footer';
import NotificationsDataManager from '../common/data-managers/notifications-data-manager';
import LoginStore from './login-store'
import AppDispatcher from '../common/app-dispatcher';
class Login extends Component {
@ -36,11 +37,17 @@ class Login extends Component {
static calculateState(prevState, props) {
// We need to work with the login store here to trigger the re-render upon state change after login
// Upon successful login, the token and currentUser are stored in the local storage as strings
const config = LoginStore.getState().config;
if (config === null) {
AppDispatcher.dispatch({
type: 'config/load',
});
}
return {
loginMessage: LoginStore.getState().loginMessage,
token: LoginStore.getState().token,
currentUser: LoginStore.getState().currentUser,
config: LoginStore.getState().config,
config: config,
}
}