Logout is redirecting to home.
This commit is contained in:
1 parent
34b07b776f
commit
f919c687f4
2 files changed
+9
-8
No files matched your search
@@ -1,12 +1,11 @@
|
||||
import React, { Component } from 'react'
|
||||
import React, { Component } from 'react';
|
||||
import {Redirect} from 'react-router';
|
||||
|
||||
class Logout extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
Login out...
|
||||
</div>
|
||||
)
|
||||
window.localStorage.removeItem("user");
|
||||
|
||||
return <Redirect to='/' />
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,11 @@ class NavBar extends Component {
|
||||
componentDidMount() {
|
||||
const getUser = window.localStorage.getItem("user");
|
||||
let user = JSON.parse(getUser)
|
||||
const authId = user.sub;
|
||||
|
||||
this.setState({ authId: authId });
|
||||
if (user) {
|
||||
const authId = user.sub;
|
||||
this.setState({ authId: authId });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in new issue
Block a user