authscape 1.0.18 → 1.0.22
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.
- package/package.json +1 -1
- package/services/apiService.js +3 -53
- package/services/authService.js +45 -1
- package/services/helper.js +13 -0
package/package.json
CHANGED
package/services/apiService.js
CHANGED
|
@@ -2,19 +2,17 @@ import axios from 'axios'
|
|
|
2
2
|
import querystring from 'querystring';
|
|
3
3
|
import fileDownload from 'js-file-download';
|
|
4
4
|
import cookies from 'next-cookies';
|
|
5
|
-
import {
|
|
5
|
+
import { setCookie, destroyCookie } from 'nookies';
|
|
6
6
|
import { GetEnvironment } from "./BaseUri";
|
|
7
|
+
import helper from "./helper";
|
|
7
8
|
|
|
8
9
|
const setupDefaultOptions = async (ctx = {}) => {
|
|
9
10
|
|
|
10
11
|
let defaultOptions = {};
|
|
11
|
-
|
|
12
|
-
if (ctx == {})
|
|
12
|
+
if (helper().isObjectEmpty(ctx))
|
|
13
13
|
{
|
|
14
14
|
let accessToken = cookies(ctx).access_token || '';
|
|
15
15
|
|
|
16
|
-
// let accessToken = window.localStorage.getItem("access_token");
|
|
17
|
-
|
|
18
16
|
if (accessToken !== null && accessToken !== undefined && accessToken != "") {
|
|
19
17
|
defaultOptions = {
|
|
20
18
|
headers: {
|
|
@@ -99,7 +97,6 @@ const apiService = (ctx = {}) => {
|
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
let baseUri = process.env.APIURI + "/api";
|
|
102
|
-
let AuthUri = process.env.AUTHORITYURI;
|
|
103
100
|
|
|
104
101
|
const instance = axios.create({
|
|
105
102
|
baseURL: baseUri,
|
|
@@ -208,53 +205,6 @@ const apiService = (ctx = {}) => {
|
|
|
208
205
|
return error.response;
|
|
209
206
|
}
|
|
210
207
|
},
|
|
211
|
-
login: async () => {
|
|
212
|
-
|
|
213
|
-
await signinRedirect(ctx);
|
|
214
|
-
},
|
|
215
|
-
logout: async () => {
|
|
216
|
-
|
|
217
|
-
let cookieDomain = process.env.cookieDomain;
|
|
218
|
-
|
|
219
|
-
destroyCookie(ctx, "access_token", {
|
|
220
|
-
maxAge: 2147483647,
|
|
221
|
-
path: '/',
|
|
222
|
-
domain: cookieDomain
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
destroyCookie(ctx, "refresh_token", {
|
|
226
|
-
maxAge: 2147483647,
|
|
227
|
-
path: '/',
|
|
228
|
-
domain: cookieDomain
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
destroyCookie(ctx, "expires_in", {
|
|
232
|
-
maxAge: 2147483647,
|
|
233
|
-
path: '/',
|
|
234
|
-
domain: cookieDomain
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
setTimeout(() => {
|
|
238
|
-
window.location.href = AuthUri + "/connect/logout?redirect=" + window.location.href;
|
|
239
|
-
}, 500);
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
signUp: (redirectUrl = null) => {
|
|
243
|
-
|
|
244
|
-
let url = "";
|
|
245
|
-
if (redirectUrl == null)
|
|
246
|
-
{
|
|
247
|
-
url = AuthUri + "/Account/Register?redirectUrl=" + window.location.href;
|
|
248
|
-
localStorage.setItem("redirectUri", window.location.href);
|
|
249
|
-
}
|
|
250
|
-
else
|
|
251
|
-
{
|
|
252
|
-
url = AuthUri + "/Account/Register?redirectUrl=" + redirectUrl;
|
|
253
|
-
localStorage.setItem("redirectUri", redirectUrl);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
window.location.href = url;
|
|
257
|
-
},
|
|
258
208
|
GetCurrentUser: async () => {
|
|
259
209
|
|
|
260
210
|
try
|
package/services/authService.js
CHANGED
|
@@ -58,7 +58,51 @@ const authService = () => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
window.location.href = loginUri;
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
signUp: (redirectUrl = null) => {
|
|
63
|
+
|
|
64
|
+
let url = "";
|
|
65
|
+
if (redirectUrl == null)
|
|
66
|
+
{
|
|
67
|
+
url = AuthUri + "/Account/Register?redirectUrl=" + window.location.href;
|
|
68
|
+
localStorage.setItem("redirectUri", window.location.href);
|
|
69
|
+
}
|
|
70
|
+
else
|
|
71
|
+
{
|
|
72
|
+
url = AuthUri + "/Account/Register?redirectUrl=" + redirectUrl;
|
|
73
|
+
localStorage.setItem("redirectUri", redirectUrl);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
window.location.href = url;
|
|
77
|
+
},
|
|
78
|
+
logout: async () => {
|
|
79
|
+
|
|
80
|
+
let AuthUri = process.env.AUTHORITYURI;
|
|
81
|
+
let cookieDomain = process.env.cookieDomain;
|
|
82
|
+
|
|
83
|
+
destroyCookie(ctx, "access_token", {
|
|
84
|
+
maxAge: 2147483647,
|
|
85
|
+
path: '/',
|
|
86
|
+
domain: cookieDomain
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
destroyCookie(ctx, "refresh_token", {
|
|
90
|
+
maxAge: 2147483647,
|
|
91
|
+
path: '/',
|
|
92
|
+
domain: cookieDomain
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
destroyCookie(ctx, "expires_in", {
|
|
96
|
+
maxAge: 2147483647,
|
|
97
|
+
path: '/',
|
|
98
|
+
domain: cookieDomain
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
window.location.href = AuthUri + "/connect/logout?redirect=" + window.location.href;
|
|
103
|
+
}, 500);
|
|
104
|
+
|
|
105
|
+
},
|
|
62
106
|
}
|
|
63
107
|
}
|
|
64
108
|
|