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 MoreIcon from '@material-ui/icons/MoreVert';
|
||||
import CancelIcon from '@material-ui/icons/Cancel';
|
||||
import ListIcon from '@material-ui/icons/FormatListBulleted';
|
||||
import { styles } from './styles';
|
||||
|
||||
import Drawer from '@material-ui/core/Drawer';
|
||||
|
@ -237,26 +238,26 @@ class App extends React.Component {
|
|||
}
|
||||
|
||||
willLogout() {
|
||||
// Modal.confirm({
|
||||
// title: 'Log out the system?',
|
||||
// content: 'Are sure sure you want to log out the system?',
|
||||
// okText: 'Confirm',
|
||||
// cancelText: 'Cancel',
|
||||
// visible: this.state.visible,
|
||||
// zIndex: 3000,
|
||||
// onOk: () => {
|
||||
// this.authStore.logout();
|
||||
// this.setState({
|
||||
// visible: false,
|
||||
// redirect: true
|
||||
// });
|
||||
// },
|
||||
// onCancel: () => {
|
||||
// this.setState({
|
||||
// visible: false,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
Modal.confirm({
|
||||
title: 'Log out the system?',
|
||||
content: 'Are sure sure you want to log out the system?',
|
||||
okText: 'Confirm',
|
||||
cancelText: 'Cancel',
|
||||
visible: this.state.visible,
|
||||
zIndex: 3000,
|
||||
onOk: () => {
|
||||
this.authStore.logout();
|
||||
this.setState({
|
||||
visible: false,
|
||||
redirect: true
|
||||
});
|
||||
},
|
||||
onCancel: () => {
|
||||
this.setState({
|
||||
visible: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openCreateProjectDialog() {
|
||||
|
@ -404,9 +405,12 @@ class App extends React.Component {
|
|||
</Link>
|
||||
<Link onClick={this
|
||||
.changeRoute
|
||||
.bind(this, '/login')} to={LINKS.LOGIN}>
|
||||
<MenuItem>Sign Out</MenuItem>
|
||||
.bind(this, '/app/transaction')} to={LINKS.TRANSACTION}>
|
||||
<MenuItem>Transaction</MenuItem>
|
||||
</Link>
|
||||
{/* <Link onClick={this.willLogout.bind(this)}> */}
|
||||
<MenuItem onClick={this.willLogout.bind(this)}>Sign Out</MenuItem>
|
||||
{/* </Link> */}
|
||||
</Menu>
|
||||
);
|
||||
|
||||
|
@ -420,14 +424,14 @@ class App extends React.Component {
|
|||
>
|
||||
{window.location.pathname.split("/")[2] == "shop" ? (
|
||||
<MenuItem>
|
||||
<IconButton color="inherit">
|
||||
<Badge badgeContent={4} color="secondary">
|
||||
<CartIcon />
|
||||
</Badge>
|
||||
</IconButton>
|
||||
<p>Cart</p>
|
||||
</MenuItem>
|
||||
) : "" }
|
||||
<IconButton color="inherit">
|
||||
<Badge badgeContent={4} color="secondary">
|
||||
<CartIcon />
|
||||
</Badge>
|
||||
</IconButton>
|
||||
<p>Cart</p>
|
||||
</MenuItem>
|
||||
) : ""}
|
||||
<MenuItem>
|
||||
<IconButton color="inherit">
|
||||
<Badge badgeContent={11} color="secondary">
|
||||
|
@ -439,39 +443,49 @@ class App extends React.Component {
|
|||
<Link onClick={this
|
||||
.changeRoute
|
||||
.bind(this, '/app/profile')} to={LINKS.PROFILE}>
|
||||
<MenuItem>
|
||||
<IconButton color="inherit">
|
||||
<AccountCircle />
|
||||
</IconButton>
|
||||
<p>Profile</p>
|
||||
</MenuItem>
|
||||
<MenuItem>
|
||||
<IconButton color="inherit">
|
||||
<AccountCircle />
|
||||
</IconButton>
|
||||
<p>Profile</p>
|
||||
</MenuItem>
|
||||
</Link>
|
||||
<Link onClick={this
|
||||
.changeRoute
|
||||
.bind(this, '/login')} to={LINKS.LOGIN}>
|
||||
<MenuItem>
|
||||
<IconButton color="inherit">
|
||||
<CancelIcon />
|
||||
</IconButton>
|
||||
<p>Sign Out</p>
|
||||
</MenuItem>
|
||||
.bind(this, '/transaction')} to={LINKS.TRANSACTION}>
|
||||
<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">
|
||||
<CancelIcon />
|
||||
</IconButton>
|
||||
<p>Sign Out</p>
|
||||
</MenuItem>
|
||||
{/* </Link> */}
|
||||
</Menu>
|
||||
);
|
||||
|
||||
const sideList = (
|
||||
<div className={classes.list}>
|
||||
<div className={classes.backgroundLogo}>
|
||||
<Link onClick={this
|
||||
.changeRoute
|
||||
.bind(this, '/app/dashboard')} to={LINKS.DASHBOARD}>
|
||||
<img
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%"
|
||||
}}
|
||||
src={applicationIcon} />
|
||||
</Link>
|
||||
<Link onClick={this
|
||||
.changeRoute
|
||||
.bind(this, '/app/dashboard')} to={LINKS.DASHBOARD}>
|
||||
<img
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%"
|
||||
}}
|
||||
src={applicationIcon} />
|
||||
</Link>
|
||||
</div>
|
||||
<Divider />
|
||||
<List>
|
||||
|
@ -515,7 +529,7 @@ class App extends React.Component {
|
|||
</List>
|
||||
<Divider />
|
||||
<List>
|
||||
<div style={{padding:15}}>
|
||||
<div style={{ padding: 15 }}>
|
||||
<a>
|
||||
<WalletComponent />
|
||||
</a>
|
||||
|
@ -553,21 +567,21 @@ class App extends React.Component {
|
|||
<AppBar position="fixed">
|
||||
<Toolbar className={classes.toolbar}>
|
||||
<div className={classes.sectionMobile}>
|
||||
<IconButton className={classes.menuButton} color="action" aria-label="Open drawer" onClick={this.toggleDrawerNew(true)}>
|
||||
<MenuIcon />
|
||||
</IconButton>
|
||||
<IconButton className={classes.menuButton} color="action" aria-label="Open drawer" onClick={this.toggleDrawerNew(true)}>
|
||||
<MenuIcon />
|
||||
</IconButton>
|
||||
</div>
|
||||
<Link onClick={this
|
||||
.changeRoute
|
||||
.bind(this, '/app/dashboard')} to={LINKS.DASHBOARD}>
|
||||
<img
|
||||
className={classes.title}
|
||||
style={{
|
||||
width: 100,
|
||||
height: 30
|
||||
}}
|
||||
src={applicationIcon} />
|
||||
</Link>
|
||||
.changeRoute
|
||||
.bind(this, '/app/dashboard')} to={LINKS.DASHBOARD}>
|
||||
<img
|
||||
className={classes.title}
|
||||
style={{
|
||||
width: 100,
|
||||
height: 30
|
||||
}}
|
||||
src={applicationIcon} />
|
||||
</Link>
|
||||
<div className={classes.search}>
|
||||
<div className={classes.searchIcon}>
|
||||
<SearchIcon />
|
||||
|
@ -587,7 +601,7 @@ class App extends React.Component {
|
|||
<Badge badgeContent={4} color="secondary">
|
||||
<CartIcon />
|
||||
</Badge>
|
||||
</IconButton>) : "" }
|
||||
</IconButton>) : ""}
|
||||
|
||||
<IconButton color="action">
|
||||
<Badge badgeContent={17} color="secondary">
|
||||
|
|
|
@ -145,9 +145,9 @@ export default class Routes extends React.Component {
|
|||
<Route
|
||||
{...rest}
|
||||
render={
|
||||
(props) => true === true
|
||||
(props) => this.authStore.isLoggedIn === true
|
||||
? (<Component {...props}/>)
|
||||
: (<Redirect to={{pathname : LINKS.LOGIN}}/>
|
||||
: (<Redirect to={{pathname : LINKS.REGISTER}}/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -86,29 +86,29 @@ export class Authentication {
|
|||
logout() {
|
||||
this.context.setToken("");
|
||||
this.context.setUserData({});
|
||||
// return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
||||
// .then(res => {
|
||||
// this.context.setToken("");
|
||||
// this.context.setUserData({});
|
||||
//
|
||||
// localStorage.removeItem('id_token');
|
||||
// localStorage.removeItem('user.name');
|
||||
// localStorage.removeItem('user.profile_image');
|
||||
// localStorage.setItem('isLoggingIn', false);
|
||||
// let cookies = document.cookie.split(";");
|
||||
// for (let i = 0; i < cookies.length; i++) {
|
||||
// this.eraseCookie(cookies[i].split("=")[0]);
|
||||
// }
|
||||
//
|
||||
// if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
||||
// window.Tawk_API.hideWidget()
|
||||
// }
|
||||
//
|
||||
// return res;
|
||||
// })
|
||||
// .catch(err => {
|
||||
// throw err;
|
||||
// })
|
||||
return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
||||
.then(res => {
|
||||
this.context.setToken("");
|
||||
this.context.setUserData({});
|
||||
|
||||
localStorage.removeItem('id_token');
|
||||
localStorage.removeItem('user.name');
|
||||
localStorage.removeItem('user.profile_image');
|
||||
localStorage.setItem('isLoggingIn', false);
|
||||
let cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
this.eraseCookie(cookies[i].split("=")[0]);
|
||||
}
|
||||
|
||||
if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
||||
window.Tawk_API.hideWidget()
|
||||
}
|
||||
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
throw err;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user