curtain-web-api 1.0.28 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -139,8 +139,9 @@ class CurtainWebAPI {
139
139
  this.user.access_token = response.data.access;
140
140
  this.user.refresh_token = response.data.refresh;
141
141
  this.user.loginStatus = true;
142
- this.user.saveIntoDB().then();
143
- return this.getUserInfo();
142
+ return this.user.saveIntoDB().then((response) => {
143
+ return this.getUserInfo();
144
+ });
144
145
  });
145
146
  }
146
147
  getUserInfo() {
@@ -189,8 +190,9 @@ class CurtainWebAPI {
189
190
  this.user.refresh_token = response.data.refresh;
190
191
  this.user.loginStatus = true;
191
192
  console.log(this.user.loginStatus);
192
- this.user.saveIntoDB().then();
193
- return this.getUserInfo();
193
+ return this.user.saveIntoDB().then((response) => {
194
+ return this.getUserInfo();
195
+ });
194
196
  });
195
197
  }
196
198
  checkIfRefreshTokenExpired() {
@@ -24,7 +24,7 @@ export declare class User {
24
24
  init(): Promise<void | undefined>;
25
25
  initiateDB(): Promise<void>;
26
26
  updateDB(): Promise<void>;
27
- saveIntoDB(): Promise<void | undefined>;
27
+ saveIntoDB(): Promise<PouchDB.Core.Response>;
28
28
  loadFromDB(): Promise<void>;
29
29
  clearDB(): Promise<void>;
30
30
  reset(): void;
@@ -87,7 +87,8 @@ class User {
87
87
  });
88
88
  }
89
89
  saveIntoDB() {
90
- this.db.get("user").catch((error) => {
90
+ console.log(this.loginStatus);
91
+ return this.db.get("user").catch((error) => {
91
92
  if (error.name === "not_found") {
92
93
  console.log(this.loginStatus);
93
94
  return {
@@ -95,7 +96,7 @@ class User {
95
96
  access_token: this.access_token,
96
97
  refresh_token: this.refresh_token,
97
98
  username: this.username,
98
- loginStatus: this.loginStatus,
99
+ loginStatus: true,
99
100
  isStaff: this.isStaff,
100
101
  id: this.id,
101
102
  totalCurtain: this.totalCurtain,
@@ -117,7 +118,7 @@ class User {
117
118
  access_token: this.access_token,
118
119
  refresh_token: this.refresh_token,
119
120
  username: this.username,
120
- loginStatus: this.loginStatus,
121
+ loginStatus: true,
121
122
  isStaff: this.isStaff,
122
123
  id: this.id,
123
124
  totalCurtain: this.totalCurtain,
@@ -128,29 +129,6 @@ class User {
128
129
  lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
129
130
  });
130
131
  });
131
- return this.db.put({
132
- _id: "user",
133
- access_token: this.access_token,
134
- refresh_token: this.refresh_token,
135
- username: this.username,
136
- loginStatus: this.loginStatus,
137
- isStaff: this.isStaff,
138
- id: this.id,
139
- totalCurtain: this.totalCurtain,
140
- canDelete: this.canDelete,
141
- curtainLinkLimit: this.curtainLinkLimit,
142
- curtainLinkLimitExceeded: this.curtainLinkLimitExceeded,
143
- lastAccessTokenUpdate: this.lastAccessTokenUpdate,
144
- lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
145
- }).then((response) => {
146
- console.log(response);
147
- }).catch((error) => {
148
- console.log(error);
149
- console.log(this.loginStatus);
150
- if (error.name === "conflict") {
151
- return this.updateDB();
152
- }
153
- });
154
132
  }
155
133
  loadFromDB() {
156
134
  return this.db.get("user").then((doc) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curtain-web-api",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -117,8 +117,9 @@ export class CurtainWebAPI {
117
117
  this.user.access_token = response.data.access;
118
118
  this.user.refresh_token = response.data.refresh;
119
119
  this.user.loginStatus = true;
120
- this.user.saveIntoDB().then();
121
- return this.getUserInfo();
120
+ return this.user.saveIntoDB().then((response) => {
121
+ return this.getUserInfo()
122
+ })
122
123
  });
123
124
  }
124
125
 
@@ -173,8 +174,9 @@ export class CurtainWebAPI {
173
174
  this.user.refresh_token = response.data.refresh;
174
175
  this.user.loginStatus = true;
175
176
  console.log(this.user.loginStatus)
176
- this.user.saveIntoDB().then();
177
- return this.getUserInfo();
177
+ return this.user.saveIntoDB().then((response) => {
178
+ return this.getUserInfo()
179
+ })
178
180
  })
179
181
  }
180
182
 
@@ -95,7 +95,8 @@ export class User {
95
95
  }
96
96
 
97
97
  saveIntoDB() {
98
- this.db.get("user").catch((error) => {
98
+ console.log(this.loginStatus)
99
+ return this.db.get("user").catch((error) => {
99
100
  if (error.name === "not_found") {
100
101
  console.log(this.loginStatus)
101
102
  return {
@@ -103,7 +104,7 @@ export class User {
103
104
  access_token: this.access_token,
104
105
  refresh_token: this.refresh_token,
105
106
  username: this.username,
106
- loginStatus: this.loginStatus,
107
+ loginStatus: true,
107
108
  isStaff: this.isStaff,
108
109
  id: this.id,
109
110
  totalCurtain: this.totalCurtain,
@@ -124,7 +125,7 @@ export class User {
124
125
  access_token: this.access_token,
125
126
  refresh_token: this.refresh_token,
126
127
  username: this.username,
127
- loginStatus: this.loginStatus,
128
+ loginStatus: true,
128
129
  isStaff: this.isStaff,
129
130
  id: this.id,
130
131
  totalCurtain: this.totalCurtain,
@@ -135,29 +136,6 @@ export class User {
135
136
  lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
136
137
  })
137
138
  })
138
- return this.db.put({
139
- _id: "user",
140
- access_token: this.access_token,
141
- refresh_token: this.refresh_token,
142
- username: this.username,
143
- loginStatus: this.loginStatus,
144
- isStaff: this.isStaff,
145
- id: this.id,
146
- totalCurtain: this.totalCurtain,
147
- canDelete: this.canDelete,
148
- curtainLinkLimit: this.curtainLinkLimit,
149
- curtainLinkLimitExceeded: this.curtainLinkLimitExceeded,
150
- lastAccessTokenUpdate: this.lastAccessTokenUpdate,
151
- lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
152
- }).then((response) => {
153
- console.log(response);
154
- }).catch((error) => {
155
- console.log(error);
156
- console.log(this.loginStatus);
157
- if (error.name === "conflict") {
158
- return this.updateDB();
159
- }
160
- });
161
139
  }
162
140
 
163
141
  loadFromDB() {