mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
user can logout
This commit is contained in:
parent
e19001ca82
commit
8da254ff9b
9 changed files with 144 additions and 93 deletions
|
@ -66,7 +66,6 @@ export class App extends React.Component {
|
|||
const fallback = () => getGuestToken({ callback: this.setUser });
|
||||
|
||||
if (id && token) {
|
||||
console.log('checking');
|
||||
checkUserToken({
|
||||
callback: this.setUser,
|
||||
fallback,
|
||||
|
@ -79,11 +78,8 @@ export class App extends React.Component {
|
|||
};
|
||||
|
||||
setUser = user => {
|
||||
console.log('hup', user);
|
||||
if (!user.token || !user.id) return;
|
||||
|
||||
console.log('setting', user);
|
||||
|
||||
this.setState({
|
||||
user: {
|
||||
...DEFAULT_USER,
|
||||
|
@ -102,6 +98,16 @@ export class App extends React.Component {
|
|||
return getData('user') || null;
|
||||
};
|
||||
|
||||
userLogout = () => {
|
||||
this.setState({
|
||||
user: {
|
||||
...DEFAULT_USER,
|
||||
}
|
||||
});
|
||||
|
||||
this.storeUserData();
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
editor,
|
||||
|
@ -120,6 +126,7 @@ export class App extends React.Component {
|
|||
<UserPanel
|
||||
user={user}
|
||||
setUser={this.setUser}
|
||||
userLogout={this.userLogout}
|
||||
/>
|
||||
|
||||
<EditorPanel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue