aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/UserStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/UserStore.js')
-rw-r--r--src/stores/UserStore.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index 09000dcdb..7dbbd955b 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -1,7 +1,9 @@
1import { observable, computed, action } from 'mobx'; 1import { observable, computed, action } from 'mobx';
2import moment from 'moment'; 2import moment from 'moment';
3import jwt from 'jsonwebtoken'; 3import jwt from 'jsonwebtoken';
4import localStorage from 'mobx-localstorage';
4 5
6import { isDevMode } from '../environment';
5import Store from './lib/Store'; 7import Store from './lib/Store';
6import Request from './lib/Request'; 8import Request from './lib/Request';
7import CachedRequest from './lib/CachedRequest'; 9import CachedRequest from './lib/CachedRequest';
@@ -98,7 +100,7 @@ export default class UserStore extends Store {
98 100
99 // Data 101 // Data
100 @computed get isLoggedIn() { 102 @computed get isLoggedIn() {
101 return this.authToken !== null && this.authToken !== undefined; 103 return Boolean(localStorage.getItem('authToken'));
102 } 104 }
103 105
104 // @computed get isTokenValid() { 106 // @computed get isTokenValid() {
@@ -160,13 +162,17 @@ export default class UserStore extends Store {
160 gaEvent('User', 'retrievePassword'); 162 gaEvent('User', 'retrievePassword');
161 } 163 }
162 164
163 @action _invite({ invites }) { 165 @action async _invite({ invites }) {
164 const data = invites.filter(invite => invite.email !== ''); 166 const data = invites.filter(invite => invite.email !== '');
165 167
166 this.inviteRequest.execute(data); 168 const response = await this.inviteRequest.execute(data)._promise;
167 169
168 // we do not wait for a server response before redirecting the user 170 this.actionStatus = response.status || [];
169 this.stores.router.push('/'); 171
172 // we do not wait for a server response before redirecting the user ONLY DURING SIGNUP
173 if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) {
174 this.stores.router.push('/');
175 }
170 176
171 gaEvent('User', 'inviteUsers'); 177 gaEvent('User', 'inviteUsers');
172 } 178 }
@@ -237,7 +243,9 @@ export default class UserStore extends Store {
237 && currentRoute.includes(this.BASE_ROUTE) 243 && currentRoute.includes(this.BASE_ROUTE)
238 && (this.hasCompletedSignup 244 && (this.hasCompletedSignup
239 || this.hasCompletedSignup === null)) { 245 || this.hasCompletedSignup === null)) {
240 this.stores.router.push('/'); 246 if (!isDevMode) {
247 this.stores.router.push('/');
248 }
241 } 249 }
242 }; 250 };
243 251