curtain-web-api 1.0.10 → 1.0.12

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.
@@ -183,13 +183,20 @@ class CurtainWebAPI {
183
183
  headers["Content-Type"] = "application/json";
184
184
  return this.axiosInstance.post(this.orcidLoginURL, JSON.stringify({ "auth_token": authorizationCode, "redirect_uri": redirectURI }), { headers: headers, responseType: "json" }).then((response) => {
185
185
  this.user.clearDB().then(() => {
186
- this.user.access_token = response.data.access;
187
- this.user.refresh_token = response.data.refresh;
188
- this.user.loginStatus = true;
189
- this.user.saveIntoDB().then(() => {
190
- });
186
+ if (this.user.loginStatus) {
187
+ this.user.access_token = response.data.access;
188
+ this.user.refresh_token = response.data.refresh;
189
+ this.user.loginStatus = true;
190
+ this.user.updateDB().then();
191
+ }
192
+ else {
193
+ this.user.access_token = response.data.access;
194
+ this.user.refresh_token = response.data.refresh;
195
+ this.user.loginStatus = true;
196
+ this.user.saveIntoDB().then(() => {
197
+ });
198
+ }
191
199
  });
192
- ;
193
200
  return response;
194
201
  }).then((response) => {
195
202
  return this.getUserInfo();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curtain-web-api",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -166,18 +166,28 @@ export class CurtainWebAPI {
166
166
  headers["Accept"] = "application/json";
167
167
  headers["Content-Type"] = "application/json";
168
168
  return this.axiosInstance.post(this.orcidLoginURL, JSON.stringify({"auth_token": authorizationCode, "redirect_uri": redirectURI}), {headers: headers, responseType:"json"}).then((response) => {
169
- this.user.clearDB().then(() => {
170
- this.user.access_token = response.data.access;
171
- this.user.refresh_token = response.data.refresh;
172
- this.user.loginStatus = true;
173
- this.user.saveIntoDB().then(
174
- () => {
169
+ this.user.clearDB().then(
170
+ () => {
171
+ if (this.user.loginStatus) {
172
+ this.user.access_token = response.data.access;
173
+ this.user.refresh_token = response.data.refresh;
174
+ this.user.loginStatus = true;
175
+ this.user.updateDB().then();
176
+ } else {
177
+ this.user.access_token = response.data.access;
178
+ this.user.refresh_token = response.data.refresh;
179
+ this.user.loginStatus = true;
180
+ this.user.saveIntoDB().then(
181
+ () => {
175
182
 
183
+ }
184
+ )
176
185
  }
177
- )
178
186
  }
179
187
  );
180
- ;
188
+
189
+
190
+
181
191
  return response;
182
192
  }).then((response) => {
183
193
  return this.getUserInfo();