diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-05 16:34:44 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-05 16:34:44 +1200 |
commit | 801b2fee9ab28d89aefeeb2d7406cf17eae9117a (patch) | |
tree | c3b69304f7558975d32e61865f8361436ddf875f /modern/src/MainToolbar.js | |
parent | 8df444bc17f84236613719f5cdc04b89b2f61f23 (diff) | |
download | trackermap-web-801b2fee9ab28d89aefeeb2d7406cf17eae9117a.tar.gz trackermap-web-801b2fee9ab28d89aefeeb2d7406cf17eae9117a.tar.bz2 trackermap-web-801b2fee9ab28d89aefeeb2d7406cf17eae9117a.zip |
Implement logout button
Diffstat (limited to 'modern/src/MainToolbar.js')
-rw-r--r-- | modern/src/MainToolbar.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js index 1420135f..0a21d945 100644 --- a/modern/src/MainToolbar.js +++ b/modern/src/MainToolbar.js @@ -10,16 +10,23 @@ import MenuIcon from '@material-ui/icons/Menu'; const styles = { flex: { flexGrow: 1 - }, - menuButton: { - marginLeft: -12, - marginRight: 20 - }, + } }; class MainToobar extends Component { constructor(props) { super(props); + this.handleLogout = this.handleLogout.bind(this); + } + + handleLogout() { + fetch("/api/session", { + method: "DELETE" + }).then(response => { + if (response.ok) { + this.props.history.push('/login'); + } + }); } render() { @@ -33,7 +40,7 @@ class MainToobar extends Component { <Typography variant="title" color="inherit" className={classes.flex}> Traccar </Typography> - <Button color="inherit">Logout</Button> + <Button color="inherit" onClick={this.handleLogout}>Logout</Button> </Toolbar> </AppBar> ); |