Skip to content

Commit cfab33d

Browse files
authored
Merge pull request #93 from netlify/actually-fix-logout
Dont start action unless there is a user
2 parents 85c6d81 + 1399e03 commit cfab33d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/state/store.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ store.signup = action(function signup(name, email, password) {
124124
});
125125

126126
store.logout = action(function logout() {
127-
store.startAction();
128-
return store.user
129-
? store.user
130-
.logout()
131-
.then(
132-
action(() => {
133-
store.user = null;
134-
store.modal.page = "login";
135-
store.saving = false;
136-
})
137-
)
138-
.catch(store.setError)
139-
: action(() => {
140-
store.modal.page = "login";
141-
store.saving = false;
142-
});
127+
if (store.user) {
128+
store.startAction();
129+
return store.user
130+
.logout()
131+
.then(
132+
action(() => {
133+
store.user = null;
134+
store.modal.page = "login";
135+
store.saving = false;
136+
})
137+
)
138+
.catch(store.setError);
139+
} else {
140+
store.modal.page = "login";
141+
store.saving = false;
142+
}
143143
});
144144

145145
store.updatePassword = action(function updatePassword(password) {

0 commit comments

Comments
 (0)