add logout in system and if not isnotlogin go to register
This commit is contained in:
parent
12e7f13c1a
commit
b5b9cd1187
|
@ -73,6 +73,7 @@ import CartIcon from '@material-ui/icons/ShoppingCart';
|
||||||
import NotificationsIcon from '@material-ui/icons/Notifications';
|
import NotificationsIcon from '@material-ui/icons/Notifications';
|
||||||
import MoreIcon from '@material-ui/icons/MoreVert';
|
import MoreIcon from '@material-ui/icons/MoreVert';
|
||||||
import CancelIcon from '@material-ui/icons/Cancel';
|
import CancelIcon from '@material-ui/icons/Cancel';
|
||||||
|
import ListIcon from '@material-ui/icons/FormatListBulleted';
|
||||||
import { styles } from './styles';
|
import { styles } from './styles';
|
||||||
|
|
||||||
import Drawer from '@material-ui/core/Drawer';
|
import Drawer from '@material-ui/core/Drawer';
|
||||||
|
@ -237,26 +238,26 @@ class App extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
willLogout() {
|
willLogout() {
|
||||||
// Modal.confirm({
|
Modal.confirm({
|
||||||
// title: 'Log out the system?',
|
title: 'Log out the system?',
|
||||||
// content: 'Are sure sure you want to log out the system?',
|
content: 'Are sure sure you want to log out the system?',
|
||||||
// okText: 'Confirm',
|
okText: 'Confirm',
|
||||||
// cancelText: 'Cancel',
|
cancelText: 'Cancel',
|
||||||
// visible: this.state.visible,
|
visible: this.state.visible,
|
||||||
// zIndex: 3000,
|
zIndex: 3000,
|
||||||
// onOk: () => {
|
onOk: () => {
|
||||||
// this.authStore.logout();
|
this.authStore.logout();
|
||||||
// this.setState({
|
this.setState({
|
||||||
// visible: false,
|
visible: false,
|
||||||
// redirect: true
|
redirect: true
|
||||||
// });
|
});
|
||||||
// },
|
},
|
||||||
// onCancel: () => {
|
onCancel: () => {
|
||||||
// this.setState({
|
this.setState({
|
||||||
// visible: false,
|
visible: false,
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openCreateProjectDialog() {
|
openCreateProjectDialog() {
|
||||||
|
@ -404,9 +405,12 @@ class App extends React.Component {
|
||||||
</Link>
|
</Link>
|
||||||
<Link onClick={this
|
<Link onClick={this
|
||||||
.changeRoute
|
.changeRoute
|
||||||
.bind(this, '/login')} to={LINKS.LOGIN}>
|
.bind(this, '/app/transaction')} to={LINKS.TRANSACTION}>
|
||||||
<MenuItem>Sign Out</MenuItem>
|
<MenuItem>Transaction</MenuItem>
|
||||||
</Link>
|
</Link>
|
||||||
|
{/* <Link onClick={this.willLogout.bind(this)}> */}
|
||||||
|
<MenuItem onClick={this.willLogout.bind(this)}>Sign Out</MenuItem>
|
||||||
|
{/* </Link> */}
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -448,14 +452,24 @@ class App extends React.Component {
|
||||||
</Link>
|
</Link>
|
||||||
<Link onClick={this
|
<Link onClick={this
|
||||||
.changeRoute
|
.changeRoute
|
||||||
.bind(this, '/login')} to={LINKS.LOGIN}>
|
.bind(this, '/transaction')} to={LINKS.TRANSACTION}>
|
||||||
<MenuItem>
|
<MenuItem>
|
||||||
|
<IconButton color="inherit">
|
||||||
|
<ListIcon />
|
||||||
|
</IconButton>
|
||||||
|
<p>Transaction</p>
|
||||||
|
</MenuItem>
|
||||||
|
</Link>
|
||||||
|
{/* <Link onClick={this
|
||||||
|
.changeRoute
|
||||||
|
.bind(this, '/login')} to={LINKS.LOGIN}> */}
|
||||||
|
<MenuItem onClick={this.willLogout.bind(this)}>
|
||||||
<IconButton color="inherit">
|
<IconButton color="inherit">
|
||||||
<CancelIcon />
|
<CancelIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<p>Sign Out</p>
|
<p>Sign Out</p>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Link>
|
{/* </Link> */}
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -145,9 +145,9 @@ export default class Routes extends React.Component {
|
||||||
<Route
|
<Route
|
||||||
{...rest}
|
{...rest}
|
||||||
render={
|
render={
|
||||||
(props) => true === true
|
(props) => this.authStore.isLoggedIn === true
|
||||||
? (<Component {...props}/>)
|
? (<Component {...props}/>)
|
||||||
: (<Redirect to={{pathname : LINKS.LOGIN}}/>
|
: (<Redirect to={{pathname : LINKS.REGISTER}}/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -86,29 +86,29 @@ export class Authentication {
|
||||||
logout() {
|
logout() {
|
||||||
this.context.setToken("");
|
this.context.setToken("");
|
||||||
this.context.setUserData({});
|
this.context.setUserData({});
|
||||||
// return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
||||||
// .then(res => {
|
.then(res => {
|
||||||
// this.context.setToken("");
|
this.context.setToken("");
|
||||||
// this.context.setUserData({});
|
this.context.setUserData({});
|
||||||
//
|
|
||||||
// localStorage.removeItem('id_token');
|
localStorage.removeItem('id_token');
|
||||||
// localStorage.removeItem('user.name');
|
localStorage.removeItem('user.name');
|
||||||
// localStorage.removeItem('user.profile_image');
|
localStorage.removeItem('user.profile_image');
|
||||||
// localStorage.setItem('isLoggingIn', false);
|
localStorage.setItem('isLoggingIn', false);
|
||||||
// let cookies = document.cookie.split(";");
|
let cookies = document.cookie.split(";");
|
||||||
// for (let i = 0; i < cookies.length; i++) {
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
// this.eraseCookie(cookies[i].split("=")[0]);
|
this.eraseCookie(cookies[i].split("=")[0]);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
||||||
// window.Tawk_API.hideWidget()
|
window.Tawk_API.hideWidget()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return res;
|
return res;
|
||||||
// })
|
})
|
||||||
// .catch(err => {
|
.catch(err => {
|
||||||
// throw err;
|
throw err;
|
||||||
// })
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user