@dexteel/mesf-core 3.11.0-alpha → 3.11.1
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const LoginWithWindowsAuthentication: () => React.JSX.Element;
|
|
2
|
+
export declare const LoginWithWindowsAuthentication: () => React.JSX.Element | null;
|
package/dist/index.esm.js
CHANGED
|
@@ -5185,6 +5185,25 @@ var MESApiService = /** @class */ (function () {
|
|
|
5185
5185
|
});
|
|
5186
5186
|
});
|
|
5187
5187
|
};
|
|
5188
|
+
MESApiService.prototype.checkIfWindowsAuthIsEnabled = function () {
|
|
5189
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5190
|
+
var resp;
|
|
5191
|
+
return __generator(this, function (_a) {
|
|
5192
|
+
switch (_a.label) {
|
|
5193
|
+
case 0:
|
|
5194
|
+
_a.trys.push([0, 2, , 3]);
|
|
5195
|
+
return [4 /*yield*/, fetch("".concat(this.config.API_AUTH_URL, "/is-windows-auth-enabled")).then(function (res) { return res.json(); })];
|
|
5196
|
+
case 1:
|
|
5197
|
+
resp = _a.sent();
|
|
5198
|
+
return [2 /*return*/, resp];
|
|
5199
|
+
case 2:
|
|
5200
|
+
_a.sent();
|
|
5201
|
+
return [2 /*return*/, false];
|
|
5202
|
+
case 3: return [2 /*return*/];
|
|
5203
|
+
}
|
|
5204
|
+
});
|
|
5205
|
+
});
|
|
5206
|
+
};
|
|
5188
5207
|
return MESApiService;
|
|
5189
5208
|
}());
|
|
5190
5209
|
|
|
@@ -5408,6 +5427,8 @@ function useToken() {
|
|
|
5408
5427
|
};
|
|
5409
5428
|
var clearUserData = function () {
|
|
5410
5429
|
localStorage.removeItem('userMESData');
|
|
5430
|
+
localStorage.removeItem('token');
|
|
5431
|
+
localStorage.removeItem('refreshToken');
|
|
5411
5432
|
setToken('');
|
|
5412
5433
|
setUserLogged(false);
|
|
5413
5434
|
};
|
|
@@ -5766,12 +5787,33 @@ var LoginWithWindowsAuthentication = function () {
|
|
|
5766
5787
|
var _a = React__default.useState(false), showError = _a[0], setShowError = _a[1];
|
|
5767
5788
|
var _b = React__default.useState(undefined), error = _b[0], setError = _b[1];
|
|
5768
5789
|
var saveUserData = React__default.useContext(AuthContext).saveUserData;
|
|
5769
|
-
var
|
|
5770
|
-
var
|
|
5771
|
-
var response;
|
|
5790
|
+
var _c = useState(false), windowsAuthIsEnabled = _c[0], setWindowsAuthIsEnabled = _c[1];
|
|
5791
|
+
var checkIfEnabled = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
5792
|
+
var apiService, response;
|
|
5772
5793
|
return __generator(this, function (_a) {
|
|
5773
5794
|
switch (_a.label) {
|
|
5774
5795
|
case 0:
|
|
5796
|
+
apiService = new MESApiService();
|
|
5797
|
+
return [4 /*yield*/, apiService.checkIfWindowsAuthIsEnabled()];
|
|
5798
|
+
case 1:
|
|
5799
|
+
response = _a.sent();
|
|
5800
|
+
if (apiService.hasErrors) {
|
|
5801
|
+
setShowError(true);
|
|
5802
|
+
setError(apiService.error);
|
|
5803
|
+
}
|
|
5804
|
+
else {
|
|
5805
|
+
setWindowsAuthIsEnabled(response !== null && response !== void 0 ? response : false);
|
|
5806
|
+
}
|
|
5807
|
+
return [2 /*return*/];
|
|
5808
|
+
}
|
|
5809
|
+
});
|
|
5810
|
+
}); };
|
|
5811
|
+
var login = useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5812
|
+
var apiService, response;
|
|
5813
|
+
return __generator(this, function (_a) {
|
|
5814
|
+
switch (_a.label) {
|
|
5815
|
+
case 0:
|
|
5816
|
+
apiService = new MESApiService();
|
|
5775
5817
|
e.preventDefault();
|
|
5776
5818
|
return [4 /*yield*/, apiService.loginWithWindowsAuthentication()];
|
|
5777
5819
|
case 1:
|
|
@@ -5786,19 +5828,28 @@ var LoginWithWindowsAuthentication = function () {
|
|
|
5786
5828
|
return [2 /*return*/];
|
|
5787
5829
|
}
|
|
5788
5830
|
});
|
|
5789
|
-
}); }
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5831
|
+
}); }, [setShowError,
|
|
5832
|
+
setError,
|
|
5833
|
+
saveUserData]);
|
|
5834
|
+
useEffect(function () {
|
|
5835
|
+
checkIfEnabled().then(function () {
|
|
5836
|
+
console.log('done');
|
|
5837
|
+
});
|
|
5838
|
+
}, []);
|
|
5839
|
+
if (windowsAuthIsEnabled)
|
|
5840
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
5841
|
+
React__default.createElement(Alert$1, { show: showError, variant: "danger", dismissible: true, onClose: function () {
|
|
5842
|
+
setShowError(false);
|
|
5843
|
+
setError(undefined);
|
|
5844
|
+
} },
|
|
5845
|
+
React__default.createElement("strong", null, "Bad credentials"),
|
|
5846
|
+
React__default.createElement("p", null,
|
|
5847
|
+
" ",
|
|
5848
|
+
error === undefined ? 'There was an error' :
|
|
5849
|
+
(error.internalError.message === undefined ? error.internalError : error.internalError.message))),
|
|
5850
|
+
React__default.createElement("div", { className: "row" },
|
|
5851
|
+
React__default.createElement("button", { className: "btn btn-primary mes-button-primary mx-auto col-md-12 mt-3 ", role: "button", onClick: login }, "Windows Auth"))));
|
|
5852
|
+
return null;
|
|
5802
5853
|
};
|
|
5803
5854
|
|
|
5804
5855
|
function Login(_a) {
|
|
@@ -5808,7 +5859,7 @@ function Login(_a) {
|
|
|
5808
5859
|
var _c = useState(''), message = _c[0], setMessage = _c[1];
|
|
5809
5860
|
var useEmailAndPassword = get$1(authConfig, 'useEmailAndPassword', true);
|
|
5810
5861
|
var useAzureAD = get$1(authConfig, 'useAzureAD', false);
|
|
5811
|
-
|
|
5862
|
+
get$1(authConfig, 'useWindowsAuth', false);
|
|
5812
5863
|
var guestIsEnabled = get$1(authConfig, 'guestIsEnabled', false);
|
|
5813
5864
|
var handleClose = function () {
|
|
5814
5865
|
setOpen(false);
|
|
@@ -5835,7 +5886,7 @@ function Login(_a) {
|
|
|
5835
5886
|
React__default.createElement("div", { className: "card-body m-3" },
|
|
5836
5887
|
useEmailAndPassword && React__default.createElement(LoginWithEmailAndPassword, null),
|
|
5837
5888
|
useAzureAD && React__default.createElement(LoginWithAzureAD, { config: authConfig.AzureConfig }),
|
|
5838
|
-
|
|
5889
|
+
React__default.createElement(LoginWithWindowsAuthentication, null),
|
|
5839
5890
|
guestIsEnabled && React__default.createElement(LoginAsGuest, null)))))),
|
|
5840
5891
|
React__default.createElement(Snackbar$1, { open: open, autoHideDuration: 6000, onClose: handleClose, message: message })));
|
|
5841
5892
|
}
|
|
@@ -35,5 +35,6 @@ export declare class MESApiService {
|
|
|
35
35
|
import(procedure: string, parameters: any[], files: any[], uniqueFile: any, database?: string): Promise<any>;
|
|
36
36
|
export(procedure: string, parameters: spParameter[], fileName: string, database?: string): Promise<string | void>;
|
|
37
37
|
exportExcel(procedure: string, parameters: spParameter[], fileName: string, excelStructure: ExportStructure, database?: string): Promise<string | void>;
|
|
38
|
+
checkIfWindowsAuthIsEnabled(): Promise<any>;
|
|
38
39
|
}
|
|
39
40
|
export {};
|