@flink-app/generic-auth-plugin 0.3.1 → 0.3.4
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/.flink/generatedHandlers.ts +2 -1
- package/.flink/generatedRepos.ts +1 -1
- package/.flink/schemas/schemas.json +42 -2
- package/.flink/schemas/schemas.ts +9 -3
- package/.flink/start.ts +1 -1
- package/dist/.flink/generatedHandlers.js +1 -1
- package/dist/.flink/generatedRepos.js +1 -1
- package/dist/.flink/schemas/schemas.d.ts +8 -2
- package/dist/.flink/schemas/schemas.json +42 -2
- package/dist/.flink/start.js +1 -1
- package/dist/src/handlers/Management/GetUserViewByUserid.d.ts +7 -0
- package/dist/src/handlers/Management/GetUserViewByUserid.js +80 -0
- package/dist/src/handlers/UserCreate.js +1 -1
- package/dist/src/handlers/UserProfilePut.js +14 -3
- package/dist/src/management.d.ts +6 -0
- package/dist/src/management.js +17 -4
- package/dist/src/schemas/Management/GetUserViewByUseridReq.d.ts +2 -0
- package/dist/src/schemas/Management/GetUserViewByUseridReq.js +2 -0
- package/dist/src/schemas/Management/GetUserViewByUseridRes.d.ts +9 -0
- package/dist/src/schemas/Management/GetUserViewByUseridRes.js +2 -0
- package/package.json +3 -3
- package/readme.md +55 -0
- package/src/handlers/Management/GetUserViewByUserid.ts +38 -0
- package/src/handlers/UserCreate.ts +43 -55
- package/src/handlers/UserProfilePut.ts +8 -2
- package/src/management.ts +152 -136
- package/src/schemas/Management/GetUserViewByUseridReq.ts +3 -0
- package/src/schemas/Management/GetUserViewByUseridRes.ts +4 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated Fri
|
|
1
|
+
// Generated Fri Mar 18 2022 13:33:52 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredHandlers, HttpMethod } from "@flink-app/flink";
|
|
3
3
|
import * as UserCreate_0 from "../src/handlers/UserCreate";
|
|
4
4
|
import * as UserLogin_0 from "../src/handlers/UserLogin";
|
|
@@ -15,6 +15,7 @@ import * as DeleteUserByUserid_0 from "../src/handlers/Management/DeleteUserByUs
|
|
|
15
15
|
import * as GetSchema_0 from "../src/handlers/Management/GetSchema";
|
|
16
16
|
import * as GetUser_0 from "../src/handlers/Management/GetUser";
|
|
17
17
|
import * as GetUserByUserid_0 from "../src/handlers/Management/GetUserByUserid";
|
|
18
|
+
import * as GetUserViewByUserid_0 from "../src/handlers/Management/GetUserViewByUserid";
|
|
18
19
|
import * as PutUserPasswordByUserid_0 from "../src/handlers/Management/PutUserPasswordByUserid";
|
|
19
20
|
import * as PutUserProfileByUserid_0 from "../src/handlers/Management/PutUserProfileByUserid";
|
|
20
21
|
import * as PutUserProfileByUseridAppend_0 from "../src/handlers/Management/PutUserProfileByUseridAppend";
|
package/.flink/generatedRepos.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated Fri
|
|
1
|
+
// Generated Fri Mar 18 2022 13:33:52 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredRepos } from "@flink-app/flink";
|
|
3
3
|
export const repos = [];
|
|
4
4
|
autoRegisteredRepos.push(...repos);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$ref": "#/definitions/Schemas",
|
|
4
4
|
"definitions": {
|
|
5
|
-
"
|
|
5
|
+
"UserCreate_7_ReqSchema": {
|
|
6
6
|
"type": "object",
|
|
7
7
|
"additionalProperties": false,
|
|
8
8
|
"properties": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"UserProfile": {
|
|
31
31
|
"type": "object"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
33
|
+
"UserCreate_7_ResSchema": {
|
|
34
34
|
"type": "object",
|
|
35
35
|
"additionalProperties": false,
|
|
36
36
|
"properties": {
|
|
@@ -425,6 +425,46 @@
|
|
|
425
425
|
],
|
|
426
426
|
"additionalProperties": false
|
|
427
427
|
},
|
|
428
|
+
"GetUserViewByUserid_6_ReqSchema": {
|
|
429
|
+
"type": "object",
|
|
430
|
+
"additionalProperties": false,
|
|
431
|
+
"properties": {}
|
|
432
|
+
},
|
|
433
|
+
"GetUserViewByUserid_6_ResSchema": {
|
|
434
|
+
"type": "object",
|
|
435
|
+
"additionalProperties": false,
|
|
436
|
+
"properties": {
|
|
437
|
+
"buttons": {
|
|
438
|
+
"type": "array",
|
|
439
|
+
"items": {
|
|
440
|
+
"type": "object",
|
|
441
|
+
"properties": {
|
|
442
|
+
"text": {
|
|
443
|
+
"type": "string"
|
|
444
|
+
},
|
|
445
|
+
"url": {
|
|
446
|
+
"type": "string"
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
"required": [
|
|
450
|
+
"text",
|
|
451
|
+
"url"
|
|
452
|
+
],
|
|
453
|
+
"additionalProperties": false
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
"data": {
|
|
457
|
+
"type": "object",
|
|
458
|
+
"additionalProperties": {
|
|
459
|
+
"type": "string"
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
"required": [
|
|
464
|
+
"buttons",
|
|
465
|
+
"data"
|
|
466
|
+
]
|
|
467
|
+
},
|
|
428
468
|
"PutUserPasswordByUserid_6_ReqSchema": {
|
|
429
469
|
"type": "object",
|
|
430
470
|
"additionalProperties": false,
|
|
@@ -18,6 +18,8 @@ import { GetManagementUserReq } from "../../src/schemas/Management/GetUserReq";
|
|
|
18
18
|
import { GetManagementUserRes } from "../../src/schemas/Management/GetUserRes";
|
|
19
19
|
import { GetManagementUserByUseridReq } from "../../src/schemas/Management/GetUserByUseridReq";
|
|
20
20
|
import { GetManagementUserByUseridRes } from "../../src/schemas/Management/GetUserByUseridRes";
|
|
21
|
+
import { GetManagementUserViewByUseridReq } from "../../src/schemas/Management/GetUserViewByUseridReq";
|
|
22
|
+
import { GetManagementUserViewByUseridRes } from "../../src/schemas/Management/GetUserViewByUseridRes";
|
|
21
23
|
import { PutManagementUserPasswordByUseridReq } from "../../src/schemas/Management/PutUserPasswordByUseridReq";
|
|
22
24
|
import { PutManagementUserPasswordByUseridRes } from "../../src/schemas/Management/PutUserPasswordByUseridRes";
|
|
23
25
|
import { PutManagementUserProfileByUseridReq } from "../../src/schemas/Management/PutUserProfileByUseridReq";
|
|
@@ -27,10 +29,10 @@ import { PutManagementUserRolesByUseridRes } from "../../src/schemas/Management/
|
|
|
27
29
|
import { PutManagementUserUsernameByUseridReq } from "../../src/schemas/Management/PutUserUsernameByUseridReq";
|
|
28
30
|
import { PutManagementUserUsernameByUseridRes } from "../../src/schemas/Management/PutUserUsernameByUseridRes";
|
|
29
31
|
|
|
30
|
-
// Generated Fri
|
|
31
|
-
export interface
|
|
32
|
+
// Generated Fri Mar 18 2022 13:33:53 GMT+0100 (Central European Standard Time)
|
|
33
|
+
export interface UserCreate_7_ReqSchema extends UserCreateReq {}
|
|
32
34
|
|
|
33
|
-
export interface
|
|
35
|
+
export interface UserCreate_7_ResSchema extends UserCreateRes {}
|
|
34
36
|
|
|
35
37
|
export interface UserLogin_7_ReqSchema extends UserLoginReq {}
|
|
36
38
|
|
|
@@ -76,6 +78,10 @@ export interface GetUserByUserid_11_ReqSchema extends GetManagementUserByUseridR
|
|
|
76
78
|
|
|
77
79
|
export interface GetUserByUserid_11_ResSchema extends GetManagementUserByUseridRes {}
|
|
78
80
|
|
|
81
|
+
export interface GetUserViewByUserid_6_ReqSchema extends GetManagementUserViewByUseridReq {}
|
|
82
|
+
|
|
83
|
+
export interface GetUserViewByUserid_6_ResSchema extends GetManagementUserViewByUseridRes {}
|
|
84
|
+
|
|
79
85
|
export interface PutUserPasswordByUserid_6_ReqSchema extends PutManagementUserPasswordByUseridReq {}
|
|
80
86
|
|
|
81
87
|
export interface PutUserPasswordByUserid_6_ResSchema extends PutManagementUserPasswordByUseridRes {}
|
package/.flink/start.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handlers = void 0;
|
|
4
|
-
// Generated Fri
|
|
4
|
+
// Generated Fri Mar 18 2022 13:33:52 GMT+0100 (Central European Standard Time)
|
|
5
5
|
var flink_1 = require("@flink-app/flink");
|
|
6
6
|
exports.handlers = [];
|
|
7
7
|
flink_1.autoRegisteredHandlers.push.apply(flink_1.autoRegisteredHandlers, exports.handlers);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.repos = void 0;
|
|
4
|
-
// Generated Fri
|
|
4
|
+
// Generated Fri Mar 18 2022 13:33:52 GMT+0100 (Central European Standard Time)
|
|
5
5
|
var flink_1 = require("@flink-app/flink");
|
|
6
6
|
exports.repos = [];
|
|
7
7
|
flink_1.autoRegisteredRepos.push.apply(flink_1.autoRegisteredRepos, exports.repos);
|
|
@@ -18,6 +18,8 @@ import { GetManagementUserReq } from "../../src/schemas/Management/GetUserReq";
|
|
|
18
18
|
import { GetManagementUserRes } from "../../src/schemas/Management/GetUserRes";
|
|
19
19
|
import { GetManagementUserByUseridReq } from "../../src/schemas/Management/GetUserByUseridReq";
|
|
20
20
|
import { GetManagementUserByUseridRes } from "../../src/schemas/Management/GetUserByUseridRes";
|
|
21
|
+
import { GetManagementUserViewByUseridReq } from "../../src/schemas/Management/GetUserViewByUseridReq";
|
|
22
|
+
import { GetManagementUserViewByUseridRes } from "../../src/schemas/Management/GetUserViewByUseridRes";
|
|
21
23
|
import { PutManagementUserPasswordByUseridReq } from "../../src/schemas/Management/PutUserPasswordByUseridReq";
|
|
22
24
|
import { PutManagementUserPasswordByUseridRes } from "../../src/schemas/Management/PutUserPasswordByUseridRes";
|
|
23
25
|
import { PutManagementUserProfileByUseridReq } from "../../src/schemas/Management/PutUserProfileByUseridReq";
|
|
@@ -26,9 +28,9 @@ import { PutManagementUserRolesByUseridReq } from "../../src/schemas/Management/
|
|
|
26
28
|
import { PutManagementUserRolesByUseridRes } from "../../src/schemas/Management/PutUserRolesByUseridRes";
|
|
27
29
|
import { PutManagementUserUsernameByUseridReq } from "../../src/schemas/Management/PutUserUsernameByUseridReq";
|
|
28
30
|
import { PutManagementUserUsernameByUseridRes } from "../../src/schemas/Management/PutUserUsernameByUseridRes";
|
|
29
|
-
export interface
|
|
31
|
+
export interface UserCreate_7_ReqSchema extends UserCreateReq {
|
|
30
32
|
}
|
|
31
|
-
export interface
|
|
33
|
+
export interface UserCreate_7_ResSchema extends UserCreateRes {
|
|
32
34
|
}
|
|
33
35
|
export interface UserLogin_7_ReqSchema extends UserLoginReq {
|
|
34
36
|
}
|
|
@@ -74,6 +76,10 @@ export interface GetUserByUserid_11_ReqSchema extends GetManagementUserByUseridR
|
|
|
74
76
|
}
|
|
75
77
|
export interface GetUserByUserid_11_ResSchema extends GetManagementUserByUseridRes {
|
|
76
78
|
}
|
|
79
|
+
export interface GetUserViewByUserid_6_ReqSchema extends GetManagementUserViewByUseridReq {
|
|
80
|
+
}
|
|
81
|
+
export interface GetUserViewByUserid_6_ResSchema extends GetManagementUserViewByUseridRes {
|
|
82
|
+
}
|
|
77
83
|
export interface PutUserPasswordByUserid_6_ReqSchema extends PutManagementUserPasswordByUseridReq {
|
|
78
84
|
}
|
|
79
85
|
export interface PutUserPasswordByUserid_6_ResSchema extends PutManagementUserPasswordByUseridRes {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$ref": "#/definitions/Schemas",
|
|
4
4
|
"definitions": {
|
|
5
|
-
"
|
|
5
|
+
"UserCreate_7_ReqSchema": {
|
|
6
6
|
"type": "object",
|
|
7
7
|
"additionalProperties": false,
|
|
8
8
|
"properties": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"UserProfile": {
|
|
31
31
|
"type": "object"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
33
|
+
"UserCreate_7_ResSchema": {
|
|
34
34
|
"type": "object",
|
|
35
35
|
"additionalProperties": false,
|
|
36
36
|
"properties": {
|
|
@@ -425,6 +425,46 @@
|
|
|
425
425
|
],
|
|
426
426
|
"additionalProperties": false
|
|
427
427
|
},
|
|
428
|
+
"GetUserViewByUserid_6_ReqSchema": {
|
|
429
|
+
"type": "object",
|
|
430
|
+
"additionalProperties": false,
|
|
431
|
+
"properties": {}
|
|
432
|
+
},
|
|
433
|
+
"GetUserViewByUserid_6_ResSchema": {
|
|
434
|
+
"type": "object",
|
|
435
|
+
"additionalProperties": false,
|
|
436
|
+
"properties": {
|
|
437
|
+
"buttons": {
|
|
438
|
+
"type": "array",
|
|
439
|
+
"items": {
|
|
440
|
+
"type": "object",
|
|
441
|
+
"properties": {
|
|
442
|
+
"text": {
|
|
443
|
+
"type": "string"
|
|
444
|
+
},
|
|
445
|
+
"url": {
|
|
446
|
+
"type": "string"
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
"required": [
|
|
450
|
+
"text",
|
|
451
|
+
"url"
|
|
452
|
+
],
|
|
453
|
+
"additionalProperties": false
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
"data": {
|
|
457
|
+
"type": "object",
|
|
458
|
+
"additionalProperties": {
|
|
459
|
+
"type": "string"
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
"required": [
|
|
464
|
+
"buttons",
|
|
465
|
+
"data"
|
|
466
|
+
]
|
|
467
|
+
},
|
|
428
468
|
"PutUserPasswordByUserid_6_ReqSchema": {
|
|
429
469
|
"type": "object",
|
|
430
470
|
"additionalProperties": false,
|
package/dist/.flink/start.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Generated Fri
|
|
3
|
+
// Generated Fri Mar 18 2022 13:33:52 GMT+0100 (Central European Standard Time)
|
|
4
4
|
require("./generatedHandlers");
|
|
5
5
|
require("./generatedRepos");
|
|
6
6
|
require("../src/index");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FlinkContext, Handler } from "@flink-app/flink";
|
|
2
|
+
import { GetManagementUserViewByUseridReq } from "../../schemas/Management/GetUserViewByUseridReq";
|
|
3
|
+
import { GetManagementUserViewByUseridRes } from "../../schemas/Management/GetUserViewByUseridRes";
|
|
4
|
+
declare const GetManagementUserByUserid: Handler<FlinkContext, GetManagementUserViewByUseridReq, GetManagementUserViewByUseridRes>;
|
|
5
|
+
export default GetManagementUserByUserid;
|
|
6
|
+
export declare const __assumedHttpMethod = "get", __file = "GetUserViewByUserid.ts", __query: never[], __params: never[];
|
|
7
|
+
export declare const __schemas: any;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
|
|
40
|
+
var flink_1 = require("@flink-app/flink");
|
|
41
|
+
var GetManagementUserByUserid = function (_a) {
|
|
42
|
+
var ctx = _a.ctx, req = _a.req, origin = _a.origin;
|
|
43
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
var pluginName, repo, user, modules, module, getData;
|
|
45
|
+
return __generator(this, function (_b) {
|
|
46
|
+
switch (_b.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
pluginName = origin || "genericAuthPlugin";
|
|
49
|
+
repo = ctx.repos[ctx.plugins[pluginName].repoName];
|
|
50
|
+
return [4 /*yield*/, repo.getById(req.params.userid)];
|
|
51
|
+
case 1:
|
|
52
|
+
user = _b.sent();
|
|
53
|
+
if (user == null) {
|
|
54
|
+
return [2 /*return*/, flink_1.notFound()];
|
|
55
|
+
}
|
|
56
|
+
modules = ctx.plugins.managementApi.moduleList.modules;
|
|
57
|
+
module = modules.find(function (p) { return p.id == origin; });
|
|
58
|
+
getData = function (user) {
|
|
59
|
+
var data = {
|
|
60
|
+
username: user.username,
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
buttons: [],
|
|
64
|
+
data: data,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
if ((module === null || module === void 0 ? void 0 : module.data.userViewGetData) != null) {
|
|
68
|
+
getData = module === null || module === void 0 ? void 0 : module.data.userViewGetData;
|
|
69
|
+
}
|
|
70
|
+
return [2 /*return*/, {
|
|
71
|
+
data: getData(user),
|
|
72
|
+
status: 200,
|
|
73
|
+
}];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
exports.default = GetManagementUserByUserid;
|
|
79
|
+
exports.__assumedHttpMethod = "get", exports.__file = "GetUserViewByUserid.ts", exports.__query = [], exports.__params = [];
|
|
80
|
+
exports.__schemas = { reqSchema: { "type": "object", "additionalProperties": false, "properties": {} }, resSchema: { "type": "object", "additionalProperties": false, "properties": { "buttons": { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string" }, "url": { "type": "string" } }, "required": ["text", "url"], "additionalProperties": false } }, "data": { "type": "object", "additionalProperties": { "type": "string" } } }, "required": ["buttons", "data"] } };
|
|
@@ -64,7 +64,7 @@ var userCreateHandler = function (_a) {
|
|
|
64
64
|
if (!re.test(username)) {
|
|
65
65
|
return [2 /*return*/, flink_1.badRequest("Username does not meet requirements", "usernameError")];
|
|
66
66
|
}
|
|
67
|
-
return [4 /*yield*/, ctx.plugins.genericAuthPlugin.createUser(repo, ctx.auth, username, password, authentificationMethod, roles, profile, ctx.plugins.genericAuthPlugin.createPasswordHashAndSaltMethod)];
|
|
67
|
+
return [4 /*yield*/, ctx.plugins.genericAuthPlugin.createUser(repo, ctx.auth, username.toLocaleLowerCase(), password, authentificationMethod, roles, profile, ctx.plugins.genericAuthPlugin.createPasswordHashAndSaltMethod)];
|
|
68
68
|
case 1:
|
|
69
69
|
createUserResponse = _c.sent();
|
|
70
70
|
if (createUserResponse.status != "success") {
|
|
@@ -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
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,7 +52,7 @@ var flink_1 = require("@flink-app/flink");
|
|
|
41
52
|
var putUserProfileHandler = function (_a) {
|
|
42
53
|
var ctx = _a.ctx, req = _a.req, origin = _a.origin;
|
|
43
54
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
-
var pluginName, repo, userId, user;
|
|
55
|
+
var pluginName, repo, userId, user, updatedProfile;
|
|
45
56
|
return __generator(this, function (_b) {
|
|
46
57
|
switch (_b.label) {
|
|
47
58
|
case 0:
|
|
@@ -54,8 +65,8 @@ var putUserProfileHandler = function (_a) {
|
|
|
54
65
|
if (user == null) {
|
|
55
66
|
return [2 /*return*/, flink_1.notFound()];
|
|
56
67
|
}
|
|
57
|
-
user.profile
|
|
58
|
-
return [4 /*yield*/, repo.updateOne(userId, { profile:
|
|
68
|
+
updatedProfile = __assign(__assign({}, user.profile), req.body);
|
|
69
|
+
return [4 /*yield*/, repo.updateOne(userId, { profile: updatedProfile })];
|
|
59
70
|
case 2:
|
|
60
71
|
_b.sent();
|
|
61
72
|
return [4 /*yield*/, repo.getById(userId)];
|
package/dist/src/management.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { ManagementApiModule } from "@flink-app/management-api-plugin";
|
|
2
|
+
import { User } from ".";
|
|
3
|
+
import { GetManagementUserViewByUseridRes } from "./schemas/Management/GetUserViewByUseridRes";
|
|
2
4
|
export interface GetManagementModuleConfig {
|
|
3
5
|
pluginId?: string;
|
|
4
6
|
profileSchema?: any;
|
|
5
7
|
ui: boolean;
|
|
8
|
+
userView?: {
|
|
9
|
+
getData(user: User): GetManagementUserViewByUseridRes;
|
|
10
|
+
};
|
|
6
11
|
uiSettings?: {
|
|
7
12
|
title: string;
|
|
8
13
|
enableUserDelete?: boolean;
|
|
9
14
|
enableUserCreate?: boolean;
|
|
10
15
|
enableUserEdit?: boolean;
|
|
16
|
+
enableUserView?: boolean;
|
|
11
17
|
};
|
|
12
18
|
}
|
|
13
19
|
export declare const GetManagementModule: (config: GetManagementModuleConfig) => ManagementApiModule;
|
package/dist/src/management.js
CHANGED
|
@@ -30,10 +30,11 @@ var PutManagementUserProfileByUserid = __importStar(require("./handlers/Manageme
|
|
|
30
30
|
var PutManagementUserUsernameByUserid = __importStar(require("./handlers/Management/PutUserUsernameByUserid"));
|
|
31
31
|
var PutManagementUserRolesByUserid = __importStar(require("./handlers/Management/PutUserRolesByUserid"));
|
|
32
32
|
var DeleteManagementUserByUserid = __importStar(require("./handlers/Management/DeleteUserByUserid"));
|
|
33
|
+
var GetUserViewByUserid = __importStar(require("./handlers/Management/GetUserViewByUserid"));
|
|
33
34
|
var PutUserProfileByUseridAppend = __importStar(require("./handlers/Management/PutUserProfileByUseridAppend"));
|
|
34
35
|
var GetSchema = __importStar(require("./handlers/Management/GetSchema"));
|
|
35
36
|
var GetManagementModule = function (config) {
|
|
36
|
-
var _a, _b, _c, _d;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
38
|
if (config.pluginId == null)
|
|
38
39
|
config.pluginId = "genericAuthPlugin";
|
|
39
40
|
var endpoints = [];
|
|
@@ -69,6 +70,14 @@ var GetManagementModule = function (config) {
|
|
|
69
70
|
},
|
|
70
71
|
handler: GetManagementUserByUserid,
|
|
71
72
|
});
|
|
73
|
+
endpoints.push({
|
|
74
|
+
routeProps: {
|
|
75
|
+
path: "/:userid/view",
|
|
76
|
+
method: flink_1.HttpMethod.get,
|
|
77
|
+
origin: config.pluginId,
|
|
78
|
+
},
|
|
79
|
+
handler: GetUserViewByUserid,
|
|
80
|
+
});
|
|
72
81
|
endpoints.push({
|
|
73
82
|
routeProps: {
|
|
74
83
|
path: "/:userid",
|
|
@@ -127,10 +136,13 @@ var GetManagementModule = function (config) {
|
|
|
127
136
|
if (((_c = config.uiSettings) === null || _c === void 0 ? void 0 : _c.enableUserEdit) == true) {
|
|
128
137
|
features.push("edit");
|
|
129
138
|
}
|
|
139
|
+
if (((_d = config.uiSettings) === null || _d === void 0 ? void 0 : _d.enableUserView) == true) {
|
|
140
|
+
features.push("view");
|
|
141
|
+
}
|
|
130
142
|
var module = {
|
|
131
143
|
id: config.pluginId || "user",
|
|
132
144
|
uiSettings: {
|
|
133
|
-
title: ((
|
|
145
|
+
title: ((_e = config.uiSettings) === null || _e === void 0 ? void 0 : _e.title) || "Users",
|
|
134
146
|
icon: "",
|
|
135
147
|
features: features,
|
|
136
148
|
},
|
|
@@ -138,8 +150,9 @@ var GetManagementModule = function (config) {
|
|
|
138
150
|
type: management_api_plugin_1.ManagementApiType.user,
|
|
139
151
|
endpoints: endpoints,
|
|
140
152
|
data: {
|
|
141
|
-
profileSchema: config.profileSchema
|
|
142
|
-
|
|
153
|
+
profileSchema: config.profileSchema,
|
|
154
|
+
userViewGetData: (_f = config.userView) === null || _f === void 0 ? void 0 : _f.getData,
|
|
155
|
+
},
|
|
143
156
|
};
|
|
144
157
|
return module;
|
|
145
158
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/generic-auth-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Flink plugin that provides a generic user authentification solution.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\"",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@flink-app/email-plugin": "^0.3.0",
|
|
20
20
|
"@flink-app/jwt-auth-plugin": "^0.3.0",
|
|
21
|
-
"@flink-app/management-api-plugin": "^0.3.
|
|
21
|
+
"@flink-app/management-api-plugin": "^0.3.3",
|
|
22
22
|
"handlebars": "^4.7.7",
|
|
23
23
|
"jsonwebtoken": "^8.5.1"
|
|
24
24
|
},
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"ts-node": "^9.1.1",
|
|
30
30
|
"typescript": "^4.2.4"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "61717a4e6bee9a2cd3e1adc0f9c74aaaee0e41ba"
|
|
33
33
|
}
|
package/readme.md
CHANGED
|
@@ -578,6 +578,7 @@ const genericAuthManagementModule = GetManagementModule(
|
|
|
578
578
|
enableUserEdit, : true //Make it possible to edit the user
|
|
579
579
|
enableUserCreate, : true //Make it possible to create new users
|
|
580
580
|
enableUserDelete, : true //Make it possible to delete the user
|
|
581
|
+
enableUserView, : true //Make it possible to view a user
|
|
581
582
|
}
|
|
582
583
|
}
|
|
583
584
|
)
|
|
@@ -612,6 +613,60 @@ function start() {
|
|
|
612
613
|
}
|
|
613
614
|
```
|
|
614
615
|
|
|
616
|
+
### Enable user viewing
|
|
617
|
+
|
|
618
|
+
To make it possible to view data for a user, you will need to first enable the `enableUserView` flag.
|
|
619
|
+
|
|
620
|
+
You can also provide a function that returns the data that should be shown of the user.
|
|
621
|
+
This function can also be extended to return a list of buttons that will be added to the toolbar.
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
```
|
|
625
|
+
import { GetManagementModule } from "@flink-app/generic-auth-plugin"
|
|
626
|
+
|
|
627
|
+
const genericAuthManagementModule = GetManagementModule(
|
|
628
|
+
{
|
|
629
|
+
ui : true, //Enable UI for this module in flink-admin-portal
|
|
630
|
+
uiSettings : {
|
|
631
|
+
title : "App users", //Title of this module
|
|
632
|
+
enableUserEdit, : true //Make it possible to edit the user
|
|
633
|
+
enableUserCreate, : true //Make it possible to create new users
|
|
634
|
+
enableUserDelete, : true //Make it possible to delete the user
|
|
635
|
+
enableUserView, : true //Make it possible to view a user
|
|
636
|
+
},
|
|
637
|
+
userView: {
|
|
638
|
+
getData(user: User) {
|
|
639
|
+
|
|
640
|
+
let data: {
|
|
641
|
+
[key: string]: string
|
|
642
|
+
} = {
|
|
643
|
+
'E-mail': user.username,
|
|
644
|
+
'Profile property' : user.profile.Property.toString()
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
let buttons: {
|
|
648
|
+
text: string
|
|
649
|
+
url: string
|
|
650
|
+
}[] = []
|
|
651
|
+
|
|
652
|
+
buttons.push({
|
|
653
|
+
text: 'Visit google',
|
|
654
|
+
url: 'https://www.google.com',
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
return {
|
|
659
|
+
buttons,
|
|
660
|
+
data,
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
}
|
|
665
|
+
)
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
615
670
|
### Make it possible to edit profile properites
|
|
616
671
|
|
|
617
672
|
To make it possible to edit profile properties when editing users, you must expose the JSON-schema of the profile.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FlinkContext, Handler, HttpMethod, notFound, RouteProps } from "@flink-app/flink";
|
|
2
|
+
import { User } from "../..";
|
|
3
|
+
import { GetManagementUserViewByUseridReq } from "../../schemas/Management/GetUserViewByUseridReq";
|
|
4
|
+
import { GetManagementUserViewByUseridRes } from "../../schemas/Management/GetUserViewByUseridRes";
|
|
5
|
+
|
|
6
|
+
const GetManagementUserByUserid: Handler<FlinkContext, GetManagementUserViewByUseridReq, GetManagementUserViewByUseridRes> = async ({ ctx, req, origin }) => {
|
|
7
|
+
let pluginName = origin || "genericAuthPlugin";
|
|
8
|
+
let repo = ctx.repos[(<any>ctx.plugins)[pluginName].repoName];
|
|
9
|
+
|
|
10
|
+
const user = await repo.getById(req.params.userid);
|
|
11
|
+
if (user == null) {
|
|
12
|
+
return notFound();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const modules = ctx.plugins.managementApi.moduleList.modules as any[];
|
|
16
|
+
const module = modules.find((p) => p.id == origin);
|
|
17
|
+
|
|
18
|
+
let getData = (user: User): GetManagementUserViewByUseridRes => {
|
|
19
|
+
let data = {
|
|
20
|
+
username: user.username,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
buttons: [],
|
|
25
|
+
data,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (module?.data.userViewGetData != null) {
|
|
30
|
+
getData = module?.data.userViewGetData as (user: User) => GetManagementUserViewByUseridRes;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
data: getData(user),
|
|
35
|
+
status: 200,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export default GetManagementUserByUserid;
|
|
@@ -1,68 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
badRequest,
|
|
3
|
-
conflict,
|
|
4
|
-
FlinkContext,
|
|
5
|
-
Handler,
|
|
6
|
-
internalServerError,
|
|
7
|
-
} from "@flink-app/flink";
|
|
1
|
+
import { badRequest, conflict, FlinkContext, Handler, internalServerError } from "@flink-app/flink";
|
|
8
2
|
import { JwtAuthPlugin } from "@flink-app/jwt-auth-plugin";
|
|
9
3
|
import { genericAuthContext } from "../genericAuthContext";
|
|
10
4
|
import { UserCreateReq } from "../schemas/UserCreateReq";
|
|
11
5
|
import { UserCreateRes } from "../schemas/UserCreateRes";
|
|
12
6
|
|
|
13
|
-
const userCreateHandler: Handler<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
if (password == null) {
|
|
28
|
-
password = "";
|
|
29
|
-
}
|
|
30
|
-
let roles: string[] = [];
|
|
31
|
-
if (profile == null) profile = {};
|
|
7
|
+
const userCreateHandler: Handler<FlinkContext<genericAuthContext>, UserCreateReq, UserCreateRes> = async ({ ctx, req, origin }) => {
|
|
8
|
+
let { password, username, authentificationMethod, profile } = req.body;
|
|
9
|
+
if (authentificationMethod == null) {
|
|
10
|
+
authentificationMethod = "password";
|
|
11
|
+
}
|
|
12
|
+
if (authentificationMethod == "password" && password == null) {
|
|
13
|
+
return internalServerError("When using password as authentification method password must be supplied");
|
|
14
|
+
}
|
|
15
|
+
if (password == null) {
|
|
16
|
+
password = "";
|
|
17
|
+
}
|
|
18
|
+
let roles: string[] = [];
|
|
19
|
+
if (profile == null) profile = {};
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
let pluginName = origin || "genericAuthPlugin";
|
|
22
|
+
let repo = ctx.repos[(<any>ctx.plugins)[pluginName].repoName];
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
var re = <RegExp>(<any>ctx.plugins)[pluginName].usernameFormat;
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
if (!re.test(username)) {
|
|
27
|
+
return badRequest("Username does not meet requirements", "usernameError");
|
|
28
|
+
}
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
const createUserResponse = await ctx.plugins.genericAuthPlugin.createUser(
|
|
31
|
+
repo,
|
|
32
|
+
<JwtAuthPlugin>ctx.auth,
|
|
33
|
+
username.toLocaleLowerCase(),
|
|
34
|
+
password,
|
|
35
|
+
authentificationMethod,
|
|
36
|
+
roles,
|
|
37
|
+
profile,
|
|
38
|
+
ctx.plugins.genericAuthPlugin.createPasswordHashAndSaltMethod
|
|
39
|
+
);
|
|
40
|
+
if (createUserResponse.status != "success") {
|
|
41
|
+
switch (createUserResponse.status) {
|
|
42
|
+
case "error":
|
|
43
|
+
return internalServerError("Unknown error", createUserResponse.status);
|
|
44
|
+
case "passwordError":
|
|
45
|
+
return badRequest("Invalid password", createUserResponse.status);
|
|
46
|
+
case "userExists":
|
|
47
|
+
return conflict("User already exists", createUserResponse.status);
|
|
48
|
+
}
|
|
60
49
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
50
|
+
return {
|
|
51
|
+
data: createUserResponse,
|
|
52
|
+
status: 200,
|
|
53
|
+
};
|
|
66
54
|
};
|
|
67
55
|
|
|
68
56
|
export default userCreateHandler;
|
|
@@ -16,8 +16,14 @@ const putUserProfileHandler: Handler<
|
|
|
16
16
|
return notFound();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
const updatedProfile = {
|
|
21
|
+
...user.profile,
|
|
22
|
+
...req.body,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
await repo.updateOne(userId, { profile: updatedProfile });
|
|
21
27
|
|
|
22
28
|
user = await repo.getById(userId);
|
|
23
29
|
|
package/src/management.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ManagementApiModule,
|
|
3
|
-
ManagementApiType,
|
|
4
|
-
} from "@flink-app/management-api-plugin";
|
|
1
|
+
import { ManagementApiModule, ManagementApiType } from "@flink-app/management-api-plugin";
|
|
5
2
|
import { HttpMethod } from "@flink-app/flink";
|
|
6
3
|
import * as userCreateHandler from "./handlers/UserCreate";
|
|
7
4
|
import * as GetManagementUser from "./handlers/Management/GetUser";
|
|
@@ -11,145 +8,164 @@ import * as PutManagementUserProfileByUserid from "./handlers/Management/PutUser
|
|
|
11
8
|
import * as PutManagementUserUsernameByUserid from "./handlers/Management/PutUserUsernameByUserid";
|
|
12
9
|
import * as PutManagementUserRolesByUserid from "./handlers/Management/PutUserRolesByUserid";
|
|
13
10
|
import * as DeleteManagementUserByUserid from "./handlers/Management/DeleteUserByUserid";
|
|
11
|
+
import * as GetUserViewByUserid from "./handlers/Management/GetUserViewByUserid";
|
|
14
12
|
|
|
15
13
|
import * as PutUserProfileByUseridAppend from "./handlers/Management/PutUserProfileByUseridAppend";
|
|
16
14
|
import * as GetSchema from "./handlers/Management/GetSchema";
|
|
15
|
+
import { User } from ".";
|
|
16
|
+
import { GetManagementUserViewByUseridRes } from "./schemas/Management/GetUserViewByUseridRes";
|
|
17
17
|
|
|
18
18
|
export interface GetManagementModuleConfig {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
pluginId?: string;
|
|
20
|
+
profileSchema?: any;
|
|
21
|
+
ui: boolean;
|
|
22
|
+
userView?: {
|
|
23
|
+
getData(user: User): GetManagementUserViewByUseridRes;
|
|
24
|
+
};
|
|
25
|
+
uiSettings?: {
|
|
26
|
+
title: string;
|
|
27
|
+
enableUserDelete?: boolean;
|
|
28
|
+
enableUserCreate?: boolean;
|
|
29
|
+
enableUserEdit?: boolean;
|
|
30
|
+
enableUserView?: boolean;
|
|
31
|
+
};
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
export const GetManagementModule = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
endpoints: endpoints,
|
|
149
|
-
data : {
|
|
150
|
-
profileSchema : config.profileSchema
|
|
34
|
+
export const GetManagementModule = (config: GetManagementModuleConfig): ManagementApiModule => {
|
|
35
|
+
if (config.pluginId == null) config.pluginId = "genericAuthPlugin";
|
|
36
|
+
|
|
37
|
+
let endpoints: ManagementApiModule["endpoints"] = [];
|
|
38
|
+
endpoints.push({
|
|
39
|
+
routeProps: {
|
|
40
|
+
path: "",
|
|
41
|
+
method: HttpMethod.post,
|
|
42
|
+
origin: config.pluginId,
|
|
43
|
+
},
|
|
44
|
+
handler: userCreateHandler,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
endpoints.push({
|
|
48
|
+
routeProps: {
|
|
49
|
+
path: "",
|
|
50
|
+
method: HttpMethod.get,
|
|
51
|
+
origin: config.pluginId,
|
|
52
|
+
},
|
|
53
|
+
handler: GetManagementUser,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
endpoints.push({
|
|
57
|
+
routeProps: {
|
|
58
|
+
path: "/profile/schema",
|
|
59
|
+
method: HttpMethod.get,
|
|
60
|
+
origin: config.pluginId || "genericAuthPlugin",
|
|
61
|
+
},
|
|
62
|
+
handler: GetSchema,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
endpoints.push({
|
|
66
|
+
routeProps: {
|
|
67
|
+
path: "/:userid",
|
|
68
|
+
method: HttpMethod.get,
|
|
69
|
+
origin: config.pluginId,
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
handler: GetManagementUserByUserid,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
endpoints.push({
|
|
76
|
+
routeProps: {
|
|
77
|
+
path: "/:userid/view",
|
|
78
|
+
method: HttpMethod.get,
|
|
79
|
+
origin: config.pluginId,
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
handler: GetUserViewByUserid,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
endpoints.push({
|
|
86
|
+
routeProps: {
|
|
87
|
+
path: "/:userid",
|
|
88
|
+
method: HttpMethod.delete,
|
|
89
|
+
origin: config.pluginId,
|
|
90
|
+
},
|
|
91
|
+
handler: DeleteManagementUserByUserid,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
endpoints.push({
|
|
95
|
+
routeProps: {
|
|
96
|
+
path: "/password/:userid",
|
|
97
|
+
method: HttpMethod.put,
|
|
98
|
+
origin: config.pluginId,
|
|
99
|
+
},
|
|
100
|
+
handler: PutManagementUserPasswordByUserid,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
endpoints.push({
|
|
104
|
+
routeProps: {
|
|
105
|
+
path: "/username/:userid",
|
|
106
|
+
method: HttpMethod.put,
|
|
107
|
+
origin: config.pluginId,
|
|
108
|
+
},
|
|
109
|
+
handler: PutManagementUserUsernameByUserid,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
endpoints.push({
|
|
113
|
+
routeProps: {
|
|
114
|
+
path: "/profile/:userid",
|
|
115
|
+
method: HttpMethod.put,
|
|
116
|
+
origin: config.pluginId,
|
|
117
|
+
},
|
|
118
|
+
handler: PutManagementUserProfileByUserid,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
endpoints.push({
|
|
122
|
+
routeProps: {
|
|
123
|
+
path: "/profile/:userid/append",
|
|
124
|
+
method: HttpMethod.put,
|
|
125
|
+
origin: config.pluginId,
|
|
126
|
+
},
|
|
127
|
+
handler: PutUserProfileByUseridAppend,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
endpoints.push({
|
|
131
|
+
routeProps: {
|
|
132
|
+
path: "/roles/:userid",
|
|
133
|
+
method: HttpMethod.put,
|
|
134
|
+
origin: config.pluginId,
|
|
135
|
+
},
|
|
136
|
+
handler: PutManagementUserRolesByUserid,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
let features: string[] = [];
|
|
140
|
+
|
|
141
|
+
if (config.uiSettings?.enableUserDelete == true) {
|
|
142
|
+
features.push("delete");
|
|
143
|
+
}
|
|
144
|
+
if (config.uiSettings?.enableUserCreate == true) {
|
|
145
|
+
features.push("create");
|
|
146
|
+
}
|
|
147
|
+
if (config.uiSettings?.enableUserEdit == true) {
|
|
148
|
+
features.push("edit");
|
|
149
|
+
}
|
|
150
|
+
if (config.uiSettings?.enableUserView == true) {
|
|
151
|
+
features.push("view");
|
|
151
152
|
}
|
|
152
|
-
};
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
let module: ManagementApiModule = {
|
|
155
|
+
id: config.pluginId || "user",
|
|
156
|
+
uiSettings: {
|
|
157
|
+
title: config.uiSettings?.title || "Users",
|
|
158
|
+
icon: "",
|
|
159
|
+
features,
|
|
160
|
+
},
|
|
161
|
+
ui: config.ui,
|
|
162
|
+
type: ManagementApiType.user,
|
|
163
|
+
endpoints: endpoints,
|
|
164
|
+
data: {
|
|
165
|
+
profileSchema: config.profileSchema,
|
|
166
|
+
userViewGetData: config.userView?.getData,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return module;
|
|
155
171
|
};
|