update: login function and purchased item store
This commit is contained in:
@@ -57,6 +57,7 @@ import Surf from './surf';
|
||||
import Odoo from './odoo';
|
||||
|
||||
import Vouchers from './vouchers';
|
||||
import {PurchasedItemStore} from "./purchased_item";
|
||||
|
||||
export default class AppState {
|
||||
http = new Http(this.token);
|
||||
@@ -115,7 +116,7 @@ export default class AppState {
|
||||
notification = new Notification(this);
|
||||
tags = new Tags(this);
|
||||
surf_turf = new Surf(this);
|
||||
|
||||
purchased_items = new PurchasedItemStore(this);
|
||||
|
||||
constructor(initialState) {
|
||||
this.token = initialState.token;
|
||||
|
||||
@@ -71,29 +71,31 @@ export class Authentication {
|
||||
|
||||
@action
|
||||
logout() {
|
||||
return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
||||
.then(res => {
|
||||
this.context.setToken("");
|
||||
this.context.setUserData({});
|
||||
|
||||
localStorage.removeItem('id_token');
|
||||
localStorage.removeItem('user.name');
|
||||
localStorage.removeItem('user.profile_image');
|
||||
localStorage.setItem('isLoggingIn', false);
|
||||
let cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
this.eraseCookie(cookies[i].split("=")[0]);
|
||||
}
|
||||
|
||||
if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
||||
window.Tawk_API.hideWidget()
|
||||
}
|
||||
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
throw err;
|
||||
})
|
||||
this.context.setToken("");
|
||||
this.context.setUserData({});
|
||||
// return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
||||
// .then(res => {
|
||||
// this.context.setToken("");
|
||||
// this.context.setUserData({});
|
||||
//
|
||||
// localStorage.removeItem('id_token');
|
||||
// localStorage.removeItem('user.name');
|
||||
// localStorage.removeItem('user.profile_image');
|
||||
// localStorage.setItem('isLoggingIn', false);
|
||||
// let cookies = document.cookie.split(";");
|
||||
// for (let i = 0; i < cookies.length; i++) {
|
||||
// this.eraseCookie(cookies[i].split("=")[0]);
|
||||
// }
|
||||
//
|
||||
// if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
||||
// window.Tawk_API.hideWidget()
|
||||
// }
|
||||
//
|
||||
// return res;
|
||||
// })
|
||||
// .catch(err => {
|
||||
// throw err;
|
||||
// })
|
||||
|
||||
}
|
||||
|
||||
@@ -248,6 +250,7 @@ export class Authentication {
|
||||
|
||||
@computed
|
||||
get isLoggedIn() {
|
||||
// alert(!!(this.context.token));
|
||||
return !!(this.context.token);
|
||||
}
|
||||
|
||||
|
||||
11
src/common/stores/purchased_item.js
Normal file
11
src/common/stores/purchased_item.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action} from "mobx/lib/mobx";
|
||||
|
||||
export class PurchasedItemStore extends BaseStore {
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
this.url = "purchased_items";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user