mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-23 00:00:02 +01:00
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
/**
|
|
* File: logout.js
|
|
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
|
* Date: 15.03.2017
|
|
* Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
|
|
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
|
**********************************************************************************/
|
|
|
|
import React, { Component } from 'react';
|
|
import { Container } from 'flux/utils';
|
|
|
|
import AppDispatcher from '../app-dispatcher';
|
|
import UserStore from '../stores/villas-store';
|
|
|
|
class Home extends Component {
|
|
static getStores() {
|
|
return [ UserStore ];
|
|
}
|
|
|
|
static calculateState() {
|
|
return {
|
|
currentUser: UserStore.getState().currentUser
|
|
};
|
|
}
|
|
|
|
componentWillMount() {
|
|
AppDispatcher.dispatch({
|
|
type: 'users/logout'
|
|
});
|
|
|
|
// discard login token
|
|
localStorage.setItem('token', '');
|
|
}
|
|
|
|
componentWillUpdate(nextProps, nextState) {
|
|
// check if logged out
|
|
if (nextState.token == null) {
|
|
// transition to login page
|
|
nextProps.router.push('/login');
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<span>Login out</span>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Container.create(Home);
|