aboutsummaryrefslogtreecommitdiff
path: root/modern/src/MainToolbar.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-05 16:34:44 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-05 16:34:44 +1200
commit801b2fee9ab28d89aefeeb2d7406cf17eae9117a (patch)
treec3b69304f7558975d32e61865f8361436ddf875f /modern/src/MainToolbar.js
parent8df444bc17f84236613719f5cdc04b89b2f61f23 (diff)
downloadetbsa-traccar-web-801b2fee9ab28d89aefeeb2d7406cf17eae9117a.tar.gz
etbsa-traccar-web-801b2fee9ab28d89aefeeb2d7406cf17eae9117a.tar.bz2
etbsa-traccar-web-801b2fee9ab28d89aefeeb2d7406cf17eae9117a.zip
Implement logout button
Diffstat (limited to 'modern/src/MainToolbar.js')
-rw-r--r--modern/src/MainToolbar.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js
index 1420135..0a21d94 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>
);