-
Notifications
You must be signed in to change notification settings - Fork 17
/
userSignOut.js
30 lines (28 loc) · 1.13 KB
/
userSignOut.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import async from 'async';
import {navigateAction} from 'fluxible-router';
export default function userSignOut(context, payload, done) {
async.series([
// (callback) => {
// context.dispatch('USER_SIGNOUT', payload);
// callback();
// },
(callback) => {
console.log(location.pathname.split('/')[location.pathname.split('/').length - 1]);
if (location.pathname.split('/').pop() !== payload.username && location.pathname.includes(payload.username))
context.executeAction(navigateAction, {url: '/'}, callback);
else if (location.pathname.split('/').pop() === 'edit') {
let newPath = location.pathname.substring(0, location.pathname.length - 4).concat('view');
context.executeAction(navigateAction, {url: newPath}, callback);
}
else
callback();
},
(callback) => {
context.deleteUser(); //clear user (is cookie) via userStoragePlugin
callback();
}
], (err, result) => {
if (err) console.log(err);
done();
});
}