@steroidsjs/core 2.2.88 → 2.2.90
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/actions/auth.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const AUTH_SET_DATA = "AUTH_SET_DATA";
|
|
|
4
4
|
export declare const AUTH_ADD_SOCIAL = "AUTH_ADD_SOCIAL";
|
|
5
5
|
export declare const init: (skipInitialized?: boolean) => (dispatch: any, getState: any) => any;
|
|
6
6
|
export declare const reInit: () => (dispatch: any, getState: any) => any;
|
|
7
|
-
export declare const login: (token: any, redirectPageId
|
|
7
|
+
export declare const login: (token: any, redirectPageId: string | boolean, params: any) => (dispatch: any, getState: any, { http }: {
|
|
8
8
|
http: any;
|
|
9
9
|
}) => any;
|
|
10
10
|
export declare const addSocial: (social: any) => {
|
package/actions/auth.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
exports.__esModule = true;
|
|
3
14
|
exports.logout = exports.setData = exports.setUser = exports.addSocial = exports.login = exports.reInit = exports.init = exports.AUTH_ADD_SOCIAL = exports.AUTH_SET_DATA = exports.AUTH_INIT_USER = exports.AUTH_INIT = void 0;
|
|
4
15
|
var router_1 = require("./router");
|
|
@@ -23,11 +34,11 @@ var init = function (skipInitialized) {
|
|
|
23
34
|
exports.init = init;
|
|
24
35
|
var reInit = function () { return exports.init(); };
|
|
25
36
|
exports.reInit = reInit;
|
|
26
|
-
var login = function (token, redirectPageId) {
|
|
37
|
+
var login = function (token, redirectPageId, params) {
|
|
27
38
|
if (redirectPageId === void 0) { redirectPageId = 'root'; }
|
|
28
39
|
return function (dispatch, getState, _a) {
|
|
29
40
|
var http = _a.http;
|
|
30
|
-
http.
|
|
41
|
+
http.onLogin(__assign({ accessToken: token }, params));
|
|
31
42
|
return dispatch({
|
|
32
43
|
type: exports.AUTH_INIT,
|
|
33
44
|
redirectPageId: redirectPageId || null
|
|
@@ -36,6 +36,9 @@ export default class HttpComponent {
|
|
|
36
36
|
getAccessToken(): Promise<any>;
|
|
37
37
|
resetConfig(): void;
|
|
38
38
|
onLogout(): void;
|
|
39
|
+
onLogin(params: {
|
|
40
|
+
accessToken: string;
|
|
41
|
+
}): void;
|
|
39
42
|
getAxiosInstance(): Promise<any>;
|
|
40
43
|
getUrl(method: any): any;
|
|
41
44
|
get(url: any, params?: {}, options?: IHttpRequestOptions): any;
|
|
@@ -176,6 +176,9 @@ var HttpComponent = /** @class */ (function () {
|
|
|
176
176
|
HttpComponent.prototype.onLogout = function () {
|
|
177
177
|
this.removeAccessToken();
|
|
178
178
|
};
|
|
179
|
+
HttpComponent.prototype.onLogin = function (params) {
|
|
180
|
+
this.setAccessToken(params.accessToken);
|
|
181
|
+
};
|
|
179
182
|
HttpComponent.prototype.getAxiosInstance = function () {
|
|
180
183
|
return __awaiter(this, void 0, void 0, function () {
|
|
181
184
|
var _a, _b, _c;
|
|
@@ -119,7 +119,7 @@ var JwtHttpComponent = /** @class */ (function (_super) {
|
|
|
119
119
|
response = _c.sent();
|
|
120
120
|
accessToken = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b[this.accessTokenKey];
|
|
121
121
|
if (accessToken) {
|
|
122
|
-
|
|
122
|
+
this.setAccessToken(accessToken);
|
|
123
123
|
originalRequest._isRetry = true;
|
|
124
124
|
originalRequest.headers.Authorization = 'Bearer ' + accessToken;
|
|
125
125
|
return [2 /*return*/, axiosInstance.request(originalRequest)];
|
|
@@ -181,6 +181,10 @@ var JwtHttpComponent = /** @class */ (function (_super) {
|
|
|
181
181
|
this.removeAccessToken();
|
|
182
182
|
this.removeRefreshToken();
|
|
183
183
|
};
|
|
184
|
+
JwtHttpComponent.prototype.onLogin = function (params) {
|
|
185
|
+
this.setAccessToken(params.accessToken);
|
|
186
|
+
this.setRefreshToken(params.refreshToken);
|
|
187
|
+
};
|
|
184
188
|
return JwtHttpComponent;
|
|
185
189
|
}(HttpComponent_1["default"]));
|
|
186
190
|
exports["default"] = JwtHttpComponent;
|