curtain-web-api 1.0.31 → 1.0.33

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.
@@ -184,9 +184,13 @@ class CurtainWebAPI {
184
184
  let headers = new axios_1.AxiosHeaders();
185
185
  headers["Accept"] = "application/json";
186
186
  headers["Content-Type"] = "application/json";
187
- return this.axiosInstance.post(this.orcidLoginURL, JSON.stringify({ "auth_token": authorizationCode, "redirect_uri": redirectURI }), { headers: headers, responseType: "json" }).then((response) => {
188
- return this.user.saveIntoDB(response.data.access, response.data.refresh).then((response) => {
189
- return this.getUserInfo();
187
+ return this.user.loadFromDB().then((response) => {
188
+ console.log(this.user);
189
+ return this.axiosInstance.post(this.orcidLoginURL, JSON.stringify({ "auth_token": authorizationCode, "redirect_uri": redirectURI }), { headers: headers, responseType: "json" }).then((response) => {
190
+ return this.user.saveIntoDB(response.data.access, response.data.refresh).then((response) => {
191
+ console.log(this.user);
192
+ return this.getUserInfo();
193
+ });
190
194
  });
191
195
  });
192
196
  }
@@ -112,6 +112,7 @@ class User {
112
112
  throw error;
113
113
  }
114
114
  }).then((doc) => {
115
+ console.log(accessToken, refreshToken);
115
116
  return this.db.put({
116
117
  _id: "user",
117
118
  _rev: doc._rev,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curtain-web-api",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -126,6 +126,7 @@ export class CurtainWebAPI {
126
126
  headers["Accept"] = "application/json";
127
127
  headers["Content-Type"] = "application/json";
128
128
  console.log(this.user)
129
+
129
130
  return this.axiosInstance.post(this.userInfoURL, {}, {headers: headers, responseType: "json"}).then((response) => {
130
131
  this.user.canDelete = response.data.can_delete;
131
132
  this.user.id = response.data.id;
@@ -167,11 +168,17 @@ export class CurtainWebAPI {
167
168
  let headers = new AxiosHeaders();
168
169
  headers["Accept"] = "application/json";
169
170
  headers["Content-Type"] = "application/json";
170
- return this.axiosInstance.post(this.orcidLoginURL, JSON.stringify({"auth_token": authorizationCode, "redirect_uri": redirectURI}), {headers: headers, responseType:"json"}).then((response) => {
171
- return this.user.saveIntoDB(response.data.access, response.data.refresh).then((response) => {
172
- return this.getUserInfo()
173
- })
174
- })
171
+ return this.user.loadFromDB().then(
172
+ (response) => {
173
+ console.log(this.user)
174
+ return this.axiosInstance.post(this.orcidLoginURL, JSON.stringify({"auth_token": authorizationCode, "redirect_uri": redirectURI}), {headers: headers, responseType:"json"}).then((response) => {
175
+ return this.user.saveIntoDB(response.data.access, response.data.refresh).then((response) => {
176
+ console.log(this.user)
177
+ return this.getUserInfo()
178
+ })
179
+ })
180
+ }
181
+ )
175
182
  }
176
183
 
177
184
  checkIfRefreshTokenExpired() {
@@ -119,6 +119,7 @@ export class User {
119
119
  throw error
120
120
  }
121
121
  }).then((doc: any) => {
122
+ console.log(accessToken, refreshToken)
122
123
  return this.db.put({
123
124
  _id: "user",
124
125
  _rev: doc._rev,