@dexteel/mesf-core 3.10.5 → 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.
- package/CHANGELOG.md +2 -0
- package/dist/account/AuthProvider.d.ts +1 -0
- package/dist/account/login-strategies/LoginWithWindowsAuthentication.d.ts +2 -0
- package/dist/configuration/pages/users/components/common/AuthTypeSelector.d.ts +7 -0
- package/dist/configuration/pages/users/models/AuthType.d.ts +4 -0
- package/dist/configuration/pages/users/models/User.d.ts +1 -1
- package/dist/configuration/pages/users/repositories/UsersRepository.d.ts +9 -0
- package/dist/index.esm.js +248 -67
- package/dist/services/ApiService.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -53,6 +53,15 @@ export declare const upsertUser: (user: User) => Promise<{
|
|
|
53
53
|
message: any;
|
|
54
54
|
data?: undefined;
|
|
55
55
|
}>;
|
|
56
|
+
export declare const getAuthTypes: () => Promise<{
|
|
57
|
+
ok: boolean;
|
|
58
|
+
message: any;
|
|
59
|
+
data?: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
ok: boolean;
|
|
62
|
+
data: any;
|
|
63
|
+
message?: undefined;
|
|
64
|
+
}>;
|
|
56
65
|
export declare const setProfilesToUser: (UserId: number, profileIds: number[]) => Promise<{
|
|
57
66
|
ok: boolean;
|
|
58
67
|
data: any;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useCallback, lazy, Suspense } from 'react';
|
|
2
|
+
import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
|
|
3
3
|
import { Outlet, useNavigate, useSearchParams, Link, useParams, Navigate, Routes, Route, BrowserRouter } from 'react-router-dom';
|
|
4
4
|
import { Typography, TextField, FormHelperText, CircularProgress as CircularProgress$1, Grid as Grid$1, Snackbar as Snackbar$1, makeStyles as makeStyles$1, createStyles as createStyles$1, Dialog as Dialog$1, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, List, ListItem, ListItemText, DialogActions as DialogActions$2 } from '@material-ui/core';
|
|
5
5
|
import { get as get$1, isEmpty } from 'lodash-es';
|
|
@@ -3767,7 +3767,7 @@ var upsertUser = function (user) { return __awaiter(void 0, void 0, void 0, func
|
|
|
3767
3767
|
parameters.push({ name: "UserName", value: user.UserName });
|
|
3768
3768
|
parameters.push({ name: "Name", value: user.FirstName });
|
|
3769
3769
|
parameters.push({ name: "LastName", value: user.LastName });
|
|
3770
|
-
parameters.push({ name: "
|
|
3770
|
+
parameters.push({ name: "AuthTypeId", value: user.AuthTypeId });
|
|
3771
3771
|
parameters.push({ name: "IsActive", value: user.IsActive });
|
|
3772
3772
|
_a.label = 1;
|
|
3773
3773
|
case 1:
|
|
@@ -3786,8 +3786,35 @@ var upsertUser = function (user) { return __awaiter(void 0, void 0, void 0, func
|
|
|
3786
3786
|
}
|
|
3787
3787
|
});
|
|
3788
3788
|
}); };
|
|
3789
|
+
var getAuthTypes = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3790
|
+
var apiService, resp, e_7;
|
|
3791
|
+
return __generator(this, function (_a) {
|
|
3792
|
+
switch (_a.label) {
|
|
3793
|
+
case 0:
|
|
3794
|
+
apiService = new MESApiService();
|
|
3795
|
+
_a.label = 1;
|
|
3796
|
+
case 1:
|
|
3797
|
+
_a.trys.push([1, 3, , 4]);
|
|
3798
|
+
return [4 /*yield*/, apiService.call("[SEC].[GetAuthTypes]", [])];
|
|
3799
|
+
case 2:
|
|
3800
|
+
resp = _a.sent();
|
|
3801
|
+
if (apiService.hasErrors) {
|
|
3802
|
+
return [2 /*return*/, { ok: false, message: apiService.error.internalError.message }];
|
|
3803
|
+
}
|
|
3804
|
+
return [2 /*return*/, {
|
|
3805
|
+
ok: true,
|
|
3806
|
+
data: resp
|
|
3807
|
+
}];
|
|
3808
|
+
case 3:
|
|
3809
|
+
e_7 = _a.sent();
|
|
3810
|
+
console.log({ e: e_7 });
|
|
3811
|
+
return [2 /*return*/, { ok: false, message: e_7.toString() }];
|
|
3812
|
+
case 4: return [2 /*return*/];
|
|
3813
|
+
}
|
|
3814
|
+
});
|
|
3815
|
+
}); };
|
|
3789
3816
|
var setProfilesToUser = function (UserId, profileIds) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3790
|
-
var apiService, parameters, resp,
|
|
3817
|
+
var apiService, parameters, resp, e_8;
|
|
3791
3818
|
return __generator(this, function (_a) {
|
|
3792
3819
|
switch (_a.label) {
|
|
3793
3820
|
case 0:
|
|
@@ -3806,8 +3833,8 @@ var setProfilesToUser = function (UserId, profileIds) { return __awaiter(void 0,
|
|
|
3806
3833
|
data: resp
|
|
3807
3834
|
}];
|
|
3808
3835
|
case 3:
|
|
3809
|
-
|
|
3810
|
-
return [2 /*return*/, { ok: false, message:
|
|
3836
|
+
e_8 = _a.sent();
|
|
3837
|
+
return [2 /*return*/, { ok: false, message: e_8.toString() }];
|
|
3811
3838
|
case 4: return [2 /*return*/];
|
|
3812
3839
|
}
|
|
3813
3840
|
});
|
|
@@ -3893,13 +3920,44 @@ var INITIAL_VALUES = {
|
|
|
3893
3920
|
UserName: "",
|
|
3894
3921
|
FirstName: "",
|
|
3895
3922
|
LastName: "",
|
|
3896
|
-
|
|
3923
|
+
AuthTypeId: 1,
|
|
3897
3924
|
IsActive: true,
|
|
3898
3925
|
LastLogin: null,
|
|
3899
3926
|
ProfilesId: [],
|
|
3900
3927
|
Profiles: []
|
|
3901
3928
|
};
|
|
3902
3929
|
|
|
3930
|
+
// @flow
|
|
3931
|
+
var AuthTypeSelector = function (_a) {
|
|
3932
|
+
var value = _a.value, onChange = _a.onChange;
|
|
3933
|
+
var _b = useState([]), authTypes = _b[0], setAuthTypes = _b[1];
|
|
3934
|
+
var _c = useState(true), isLoading = _c[0], setIsLoading = _c[1];
|
|
3935
|
+
var _d = useState(''), error = _d[0], setError = _d[1];
|
|
3936
|
+
var selectedAuthTypeName = useMemo(function () {
|
|
3937
|
+
var _a;
|
|
3938
|
+
return ((_a = authTypes.find(function (authType) { return authType.AuthTypeId === value; })) === null || _a === void 0 ? void 0 : _a.Name) || 'Empty';
|
|
3939
|
+
}, [authTypes, value]);
|
|
3940
|
+
useEffect(function () {
|
|
3941
|
+
setIsLoading(true);
|
|
3942
|
+
getAuthTypes()
|
|
3943
|
+
.then(function (resp) {
|
|
3944
|
+
if (resp.ok) {
|
|
3945
|
+
setAuthTypes(get$1(resp, 'data.tables[0].rows', []));
|
|
3946
|
+
setIsLoading(false);
|
|
3947
|
+
}
|
|
3948
|
+
else {
|
|
3949
|
+
setIsLoading(false);
|
|
3950
|
+
setError(resp.message);
|
|
3951
|
+
}
|
|
3952
|
+
});
|
|
3953
|
+
}, []);
|
|
3954
|
+
return (React.createElement(React.Fragment, null,
|
|
3955
|
+
(!isLoading && authTypes.length) ? (React.createElement(FormControl, { variant: 'outlined', fullWidth: true },
|
|
3956
|
+
React.createElement(InputLabel, { id: "auth-type-label" }, "Auth Type"),
|
|
3957
|
+
React.createElement(Select, { fullWidth: true, labelId: "auth-type-label", id: "auth-type-id", value: value, onChange: onChange, input: React.createElement(Input, { id: "select-multiple-chip" }), renderValue: function (selected) { return (React.createElement(Chip, { key: "selected-authType-".concat(selected), label: selectedAuthTypeName })); } }, authTypes.map(function (authType) { return (React.createElement(MenuItem, { key: "authType-".concat(authType.AuthTypeId), value: authType.AuthTypeId }, authType.Name)); })))) : null,
|
|
3958
|
+
!isLoading && error ? (React.createElement(Alert$2, { color: 'error' }, error)) : null));
|
|
3959
|
+
};
|
|
3960
|
+
|
|
3903
3961
|
var useStyles$4 = makeStyles(function (theme) {
|
|
3904
3962
|
return createStyles({
|
|
3905
3963
|
checkbox: {
|
|
@@ -3986,25 +4044,23 @@ var CreateUser = function (_a) {
|
|
|
3986
4044
|
React.createElement(Grid, { item: true, md: 6, xs: 12 },
|
|
3987
4045
|
React.createElement(TextField, __assign({}, register("LastName", { required: true }), { label: "Last name", variant: "outlined", error: !!errors.FirstName, fullWidth: true, margin: "dense", autoComplete: 'off' })),
|
|
3988
4046
|
((_d = errors.LastName) === null || _d === void 0 ? void 0 : _d.type) === 'required' && React.createElement("span", { className: classes.errorLabel }, "Last name is required")),
|
|
3989
|
-
React.createElement(Grid, { item: true, container: true, xs: 12, spacing:
|
|
3990
|
-
React.createElement(Grid, { item: true,
|
|
3991
|
-
React.createElement(
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
return (React.createElement(FormControlLabel, { className: classes.checkbox, control: React.createElement(Checkbox, { checked: field.value, onChange: field.onChange, name: "IsActive", color: "primary" }), label: "Active" }));
|
|
4007
|
-
} })))))),
|
|
4047
|
+
React.createElement(Grid, { item: true, container: true, xs: 12, spacing: 3 },
|
|
4048
|
+
React.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4049
|
+
React.createElement(Controller, { name: "ProfilesId", control: control, rules: { required: true }, render: function (_a) {
|
|
4050
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
4051
|
+
return (React.createElement(ProfilesPicker, { onChange: onChange, value: value, userIdForDelete: null }));
|
|
4052
|
+
} }),
|
|
4053
|
+
errors.ProfilesId && React.createElement("span", { className: classes.errorLabel }, "Select a profile(s)")),
|
|
4054
|
+
React.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4055
|
+
React.createElement(Controller, { name: "AuthTypeId", control: control, render: function (_a) {
|
|
4056
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
4057
|
+
return (React.createElement(AuthTypeSelector, { value: value, onChange: onChange }));
|
|
4058
|
+
} })),
|
|
4059
|
+
React.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4060
|
+
React.createElement(Controller, { name: "IsActive", control: control, render: function (_a) {
|
|
4061
|
+
var field = _a.field;
|
|
4062
|
+
return (React.createElement(FormControlLabel, { className: classes.checkbox, control: React.createElement(Checkbox, { checked: field.value, onChange: field.onChange, name: "IsActive", color: "primary" }), label: "Active" }));
|
|
4063
|
+
} }))))),
|
|
4008
4064
|
React.createElement(Modal$2.Footer, { style: { padding: "20px 30px 30px" } },
|
|
4009
4065
|
React.createElement(Grid, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
4010
4066
|
React.createElement(Grid, { item: true, md: 3, xs: 12 },
|
|
@@ -4094,7 +4150,7 @@ var EditUser = function (_a) {
|
|
|
4094
4150
|
setValue("UserName", userSelected.UserName);
|
|
4095
4151
|
setValue("FirstName", userSelected.FirstName);
|
|
4096
4152
|
setValue("LastName", userSelected.LastName);
|
|
4097
|
-
setValue("
|
|
4153
|
+
setValue("AuthTypeId", userSelected.AuthTypeId);
|
|
4098
4154
|
setValue("IsActive", userSelected.IsActive);
|
|
4099
4155
|
setValue("LastLogin", userSelected.LastLogin);
|
|
4100
4156
|
setValue("ProfilesId", profilesIds.map(function (pId) { return parseInt(pId); }));
|
|
@@ -4126,25 +4182,23 @@ var EditUser = function (_a) {
|
|
|
4126
4182
|
React.createElement(Grid, { item: true, md: 6, xs: 12 },
|
|
4127
4183
|
React.createElement(TextField, __assign({}, register("LastName", { required: true }), { label: "Last name", variant: "outlined", error: !!errors.FirstName, fullWidth: true, margin: "dense", autoComplete: 'off' })),
|
|
4128
4184
|
((_d = errors.LastName) === null || _d === void 0 ? void 0 : _d.type) === 'required' && React.createElement("span", { className: classes.errorLabel }, "Last name is required")),
|
|
4129
|
-
React.createElement(Grid, { item: true, container: true, xs: 12, spacing:
|
|
4130
|
-
React.createElement(Grid, { item: true,
|
|
4131
|
-
React.createElement(
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
return (React.createElement(FormControlLabel, { className: classes.checkbox, control: React.createElement(Checkbox, { checked: field.value, onChange: field.onChange, name: "IsActive", color: "primary" }), label: "Active" }));
|
|
4147
|
-
} })))))))),
|
|
4185
|
+
React.createElement(Grid, { item: true, container: true, xs: 12, spacing: 3 },
|
|
4186
|
+
React.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4187
|
+
React.createElement(Controller, { name: "ProfilesId", control: control, rules: { required: true }, render: function (_a) {
|
|
4188
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
4189
|
+
return (React.createElement(ProfilesPicker, { onChange: onChange, value: value, userIdForDelete: null }));
|
|
4190
|
+
} }),
|
|
4191
|
+
errors.ProfilesId && React.createElement("span", { className: classes.errorLabel }, "Select a profile(s)")),
|
|
4192
|
+
React.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4193
|
+
React.createElement(Controller, { name: "AuthTypeId", control: control, render: function (_a) {
|
|
4194
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
4195
|
+
return (React.createElement(AuthTypeSelector, { value: value, onChange: onChange }));
|
|
4196
|
+
} })),
|
|
4197
|
+
React.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4198
|
+
React.createElement(Controller, { name: "IsActive", control: control, render: function (_a) {
|
|
4199
|
+
var field = _a.field;
|
|
4200
|
+
return (React.createElement(FormControlLabel, { className: classes.checkbox, control: React.createElement(Checkbox, { checked: field.value, onChange: field.onChange, name: "IsActive", color: "primary" }), label: "Active" }));
|
|
4201
|
+
} }))))))),
|
|
4148
4202
|
React.createElement(Modal$2.Footer, { style: { padding: "20px 30px 30px" } },
|
|
4149
4203
|
React.createElement(Grid, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
4150
4204
|
React.createElement(Grid, { item: true, md: 3, xs: 12, style: { margin: 0 } },
|
|
@@ -4197,7 +4251,7 @@ var DeleteUser = function (_a) {
|
|
|
4197
4251
|
setValue("UserName", userSelected.UserName);
|
|
4198
4252
|
setValue("FirstName", userSelected.FirstName);
|
|
4199
4253
|
setValue("LastName", userSelected.LastName);
|
|
4200
|
-
setValue("
|
|
4254
|
+
setValue("AuthTypeId", userSelected.AuthTypeId);
|
|
4201
4255
|
setValue("IsActive", userSelected.IsActive);
|
|
4202
4256
|
setValue("LastLogin", userSelected.LastLogin);
|
|
4203
4257
|
setValue("ProfilesId", profilesIds.map(function (pId) { return parseInt(pId); }));
|
|
@@ -4249,24 +4303,22 @@ var DeleteUser = function (_a) {
|
|
|
4249
4303
|
React__default.createElement(TextField, __assign({}, register("FirstName", { required: true }), { label: "First name", variant: "outlined", disabled: true, fullWidth: true, margin: "dense", autoComplete: 'off' }))),
|
|
4250
4304
|
React__default.createElement(Grid, { item: true, md: 6, xs: 12 },
|
|
4251
4305
|
React__default.createElement(TextField, __assign({}, register("LastName", { required: true }), { label: "Last name", variant: "outlined", disabled: true, fullWidth: true, margin: "dense", autoComplete: 'off' }))),
|
|
4252
|
-
React__default.createElement(Grid, { item: true, container: true, xs: 12, spacing:
|
|
4253
|
-
React__default.createElement(Grid, { item: true,
|
|
4254
|
-
React__default.createElement(
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
return (React__default.createElement(FormControlLabel, { control: React__default.createElement(Checkbox, { disabled: true, checked: field.value, onChange: field.onChange, name: "IsActive", color: "primary" }), label: "Active" }));
|
|
4269
|
-
} })))))))),
|
|
4306
|
+
React__default.createElement(Grid, { item: true, container: true, xs: 12, spacing: 3 },
|
|
4307
|
+
React__default.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4308
|
+
React__default.createElement(Controller, { name: "ProfilesId", control: control, rules: { required: true }, render: function (_a) {
|
|
4309
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
4310
|
+
return (React__default.createElement(ProfilesPicker, { onChange: onChange, value: value, userIdForDelete: null }));
|
|
4311
|
+
} })),
|
|
4312
|
+
React__default.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4313
|
+
React__default.createElement(Controller, { name: "AuthTypeId", control: control, render: function (_a) {
|
|
4314
|
+
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
4315
|
+
return (React__default.createElement(AuthTypeSelector, { value: value, onChange: onChange }));
|
|
4316
|
+
} })),
|
|
4317
|
+
React__default.createElement(Grid, { item: true, xs: 12, md: 6 },
|
|
4318
|
+
React__default.createElement(Controller, { name: "IsActive", control: control, render: function (_a) {
|
|
4319
|
+
var field = _a.field;
|
|
4320
|
+
return (React__default.createElement(FormControlLabel, { control: React__default.createElement(Checkbox, { checked: field.value, onChange: field.onChange, name: "IsActive", color: "primary" }), label: "Active" }));
|
|
4321
|
+
} }))))))),
|
|
4270
4322
|
React__default.createElement(Modal$2.Footer, { style: { padding: "20px 30px 30px" } },
|
|
4271
4323
|
React__default.createElement(Grid, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
4272
4324
|
React__default.createElement(Grid, { item: true, md: 3, xs: 12, style: { margin: 0 } },
|
|
@@ -4755,7 +4807,44 @@ var MESApiService = /** @class */ (function () {
|
|
|
4755
4807
|
isError = { ok: true };
|
|
4756
4808
|
data = {};
|
|
4757
4809
|
data.AccessToken = accessToken;
|
|
4758
|
-
return [2 /*return*/, fetch(this.config.API_AUTH_URL + '/authenticate
|
|
4810
|
+
return [2 /*return*/, fetch(this.config.API_AUTH_URL + '/authenticate/azure-ad', {
|
|
4811
|
+
method: "POST",
|
|
4812
|
+
mode: "cors",
|
|
4813
|
+
headers: {
|
|
4814
|
+
"Content-Type": "application/json"
|
|
4815
|
+
},
|
|
4816
|
+
body: JSON.stringify(data)
|
|
4817
|
+
})["catch"](function (errorMsg) {
|
|
4818
|
+
throw new FetchError(errorMsg.message, 404, "ERR_CONNECTION_REFUSED");
|
|
4819
|
+
})
|
|
4820
|
+
.then(function (response) {
|
|
4821
|
+
isError = { ok: response.ok, status: response.status, statusText: response.statusText };
|
|
4822
|
+
return response.json();
|
|
4823
|
+
})
|
|
4824
|
+
.then(function (object) {
|
|
4825
|
+
if (!isError.ok)
|
|
4826
|
+
throw new FetchError(isError.statusText, isError.status, object);
|
|
4827
|
+
return object;
|
|
4828
|
+
})["catch"](function (err) {
|
|
4829
|
+
_this.hasErrors = true;
|
|
4830
|
+
_this.error = err;
|
|
4831
|
+
return {
|
|
4832
|
+
hasErrors: true,
|
|
4833
|
+
error: err
|
|
4834
|
+
};
|
|
4835
|
+
})];
|
|
4836
|
+
});
|
|
4837
|
+
});
|
|
4838
|
+
};
|
|
4839
|
+
MESApiService.prototype.loginWithWindowsAuthentication = function () {
|
|
4840
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4841
|
+
var isError, data;
|
|
4842
|
+
var _this = this;
|
|
4843
|
+
return __generator(this, function (_a) {
|
|
4844
|
+
this.prepareCall();
|
|
4845
|
+
isError = { ok: true };
|
|
4846
|
+
data = {};
|
|
4847
|
+
return [2 /*return*/, fetch(this.config.API_AUTH_URL + '/authenticate/windows', {
|
|
4759
4848
|
method: "POST",
|
|
4760
4849
|
mode: "cors",
|
|
4761
4850
|
headers: {
|
|
@@ -5096,6 +5185,25 @@ var MESApiService = /** @class */ (function () {
|
|
|
5096
5185
|
});
|
|
5097
5186
|
});
|
|
5098
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
|
+
};
|
|
5099
5207
|
return MESApiService;
|
|
5100
5208
|
}());
|
|
5101
5209
|
|
|
@@ -5319,6 +5427,8 @@ function useToken() {
|
|
|
5319
5427
|
};
|
|
5320
5428
|
var clearUserData = function () {
|
|
5321
5429
|
localStorage.removeItem('userMESData');
|
|
5430
|
+
localStorage.removeItem('token');
|
|
5431
|
+
localStorage.removeItem('refreshToken');
|
|
5322
5432
|
setToken('');
|
|
5323
5433
|
setUserLogged(false);
|
|
5324
5434
|
};
|
|
@@ -5404,7 +5514,7 @@ var Account = function () {
|
|
|
5404
5514
|
setUserName(userData[0].UserName);
|
|
5405
5515
|
setUserLastName(userData[0].LastName);
|
|
5406
5516
|
setUserFirstName(userData[0].FirstName);
|
|
5407
|
-
setUserIsDomain(userData[0].
|
|
5517
|
+
setUserIsDomain(userData[0].AuthTypeId);
|
|
5408
5518
|
setUserIsActive(userData[0].IsActive);
|
|
5409
5519
|
setUserProfiles(stringToList((userData[0].Profiles || '')));
|
|
5410
5520
|
setUserProcedures(stringToList((userData[0].Procedures || '')));
|
|
@@ -5621,7 +5731,7 @@ var LoginWithAzureADForm = function () {
|
|
|
5621
5731
|
}); };
|
|
5622
5732
|
return (React__default.createElement("form", { onSubmit: login },
|
|
5623
5733
|
React__default.createElement("div", { className: "row" },
|
|
5624
|
-
React__default.createElement("button", { className: "btn btn-primary mes-button-primary mx-auto col-md-12 mt-3 ", type: "submit" }, "Login with
|
|
5734
|
+
React__default.createElement("button", { className: "btn btn-primary mes-button-primary mx-auto col-md-12 mt-3 ", type: "submit" }, "Login with Azure AD"))));
|
|
5625
5735
|
};
|
|
5626
5736
|
|
|
5627
5737
|
var LoginWithAzureAD = function (_a) {
|
|
@@ -5673,6 +5783,75 @@ var LoginAsGuest = function () {
|
|
|
5673
5783
|
React__default.createElement("button", { className: "btn btn-primary mes-button-primary mx-auto col-md-12 mt-3 ", role: "button", onClick: loginAsGuest }, "Guest"))));
|
|
5674
5784
|
};
|
|
5675
5785
|
|
|
5786
|
+
var LoginWithWindowsAuthentication = function () {
|
|
5787
|
+
var _a = React__default.useState(false), showError = _a[0], setShowError = _a[1];
|
|
5788
|
+
var _b = React__default.useState(undefined), error = _b[0], setError = _b[1];
|
|
5789
|
+
var saveUserData = React__default.useContext(AuthContext).saveUserData;
|
|
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;
|
|
5793
|
+
return __generator(this, function (_a) {
|
|
5794
|
+
switch (_a.label) {
|
|
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();
|
|
5817
|
+
e.preventDefault();
|
|
5818
|
+
return [4 /*yield*/, apiService.loginWithWindowsAuthentication()];
|
|
5819
|
+
case 1:
|
|
5820
|
+
response = _a.sent();
|
|
5821
|
+
if (apiService.hasErrors) {
|
|
5822
|
+
setShowError(true);
|
|
5823
|
+
setError(apiService.error);
|
|
5824
|
+
}
|
|
5825
|
+
else {
|
|
5826
|
+
saveUserData(response);
|
|
5827
|
+
}
|
|
5828
|
+
return [2 /*return*/];
|
|
5829
|
+
}
|
|
5830
|
+
});
|
|
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;
|
|
5853
|
+
};
|
|
5854
|
+
|
|
5676
5855
|
function Login(_a) {
|
|
5677
5856
|
var authConfig = _a.authConfig;
|
|
5678
5857
|
var params = useRef((new URL(document.location)).searchParams);
|
|
@@ -5680,6 +5859,7 @@ function Login(_a) {
|
|
|
5680
5859
|
var _c = useState(''), message = _c[0], setMessage = _c[1];
|
|
5681
5860
|
var useEmailAndPassword = get$1(authConfig, 'useEmailAndPassword', true);
|
|
5682
5861
|
var useAzureAD = get$1(authConfig, 'useAzureAD', false);
|
|
5862
|
+
get$1(authConfig, 'useWindowsAuth', false);
|
|
5683
5863
|
var guestIsEnabled = get$1(authConfig, 'guestIsEnabled', false);
|
|
5684
5864
|
var handleClose = function () {
|
|
5685
5865
|
setOpen(false);
|
|
@@ -5706,6 +5886,7 @@ function Login(_a) {
|
|
|
5706
5886
|
React__default.createElement("div", { className: "card-body m-3" },
|
|
5707
5887
|
useEmailAndPassword && React__default.createElement(LoginWithEmailAndPassword, null),
|
|
5708
5888
|
useAzureAD && React__default.createElement(LoginWithAzureAD, { config: authConfig.AzureConfig }),
|
|
5889
|
+
React__default.createElement(LoginWithWindowsAuthentication, null),
|
|
5709
5890
|
guestIsEnabled && React__default.createElement(LoginAsGuest, null)))))),
|
|
5710
5891
|
React__default.createElement(Snackbar$1, { open: open, autoHideDuration: 6000, onClose: handleClose, message: message })));
|
|
5711
5892
|
}
|
|
@@ -28,11 +28,13 @@ export declare class MESApiService {
|
|
|
28
28
|
changePassword(userId: string, password: string): Promise<any>;
|
|
29
29
|
authenticate(userName: string, password: string): Promise<any>;
|
|
30
30
|
loginWithAzureAD(accessToken: string): Promise<any>;
|
|
31
|
+
loginWithWindowsAuthentication(): Promise<any>;
|
|
31
32
|
uploadFiles(selectedFiles: File[], folderName?: string): Promise<any>;
|
|
32
33
|
call(procedure: string, parameters: any[], database?: string): Promise<any>;
|
|
33
34
|
callJSON(procedure: string, parameters: any[], database?: string): Promise<any>;
|
|
34
35
|
import(procedure: string, parameters: any[], files: any[], uniqueFile: any, database?: string): Promise<any>;
|
|
35
36
|
export(procedure: string, parameters: spParameter[], fileName: string, database?: string): Promise<string | void>;
|
|
36
37
|
exportExcel(procedure: string, parameters: spParameter[], fileName: string, excelStructure: ExportStructure, database?: string): Promise<string | void>;
|
|
38
|
+
checkIfWindowsAuthIsEnabled(): Promise<any>;
|
|
37
39
|
}
|
|
38
40
|
export {};
|