@formio/appserver 1.0.0

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.
Files changed (49) hide show
  1. package/README.md +61 -0
  2. package/lib/actions/index.d.ts +160 -0
  3. package/lib/actions/index.js +10 -0
  4. package/lib/actions/login/LoginAction.d.ts +110 -0
  5. package/lib/actions/login/LoginAction.js +288 -0
  6. package/lib/actions/role/RoleAction.d.ts +62 -0
  7. package/lib/actions/role/RoleAction.js +171 -0
  8. package/lib/actions/save/SaveAction.d.ts +29 -0
  9. package/lib/actions/save/SaveAction.js +307 -0
  10. package/lib/auth.d.ts +5 -0
  11. package/lib/auth.js +70 -0
  12. package/lib/db.d.ts +76 -0
  13. package/lib/db.js +384 -0
  14. package/lib/index.d.ts +167 -0
  15. package/lib/index.js +18 -0
  16. package/lib/prepare/access.d.ts +3 -0
  17. package/lib/prepare/access.js +62 -0
  18. package/lib/prepare/bcrypt.d.ts +3 -0
  19. package/lib/prepare/bcrypt.js +25 -0
  20. package/lib/prepare/index.d.ts +10 -0
  21. package/lib/prepare/index.js +54 -0
  22. package/lib/prepare/password.d.ts +3 -0
  23. package/lib/prepare/password.js +28 -0
  24. package/lib/prepare/persist.d.ts +3 -0
  25. package/lib/prepare/persist.js +24 -0
  26. package/lib/prepare/protect.d.ts +3 -0
  27. package/lib/prepare/protect.js +28 -0
  28. package/lib/process/calculate.d.ts +3 -0
  29. package/lib/process/calculate.js +23 -0
  30. package/lib/process/conditions.d.ts +3 -0
  31. package/lib/process/conditions.js +54 -0
  32. package/lib/process/fetch.d.ts +3 -0
  33. package/lib/process/fetch.js +61 -0
  34. package/lib/process/index.d.ts +9 -0
  35. package/lib/process/index.js +56 -0
  36. package/lib/process/validate.d.ts +3 -0
  37. package/lib/process/validate.js +14 -0
  38. package/lib/types/action.d.ts +7 -0
  39. package/lib/types/action.js +2 -0
  40. package/lib/types/form.d.ts +4 -0
  41. package/lib/types/form.js +2 -0
  42. package/lib/types/project.d.ts +4 -0
  43. package/lib/types/project.js +2 -0
  44. package/lib/types/server.d.ts +75 -0
  45. package/lib/types/server.js +2 -0
  46. package/lib/types/submission.d.ts +38 -0
  47. package/lib/types/submission.js +2 -0
  48. package/package.json +48 -0
  49. package/server.js +3 -0
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ ## Form.io Application Server
2
+ The Form.io Application Server is a performant run-time application server used to serve single project templates (including forms, resources, roles, etc) at a single deployed endpoint. It's goal is to enable rapid single tenant deployments where you wish to manage all Forms and Resources within a single location, but store the tenant data within their own database.
3
+
4
+ ### Installation
5
+ To use this library, you must mount it within an Express.js application. As an example, you can create a simple Express.js application with this library by first creating a new [Express.js application](https://expressjs.com/en/starter/installing.html) and then install and use the Server as follows.
6
+
7
+ ```
8
+ npm install --save @formio/appserver
9
+ ```
10
+
11
+ Then within your server.js file, you would add the following.
12
+
13
+ ```js
14
+ const express = require('express');
15
+ const app = express();
16
+ const { Server, Modules } = require('@formio/appserver');
17
+
18
+ // Declare our new server instance.
19
+ const server = new Server({
20
+ db: new Modules.db({
21
+ url: "mongodb://localhost:27017/subserver",
22
+ config: {}
23
+ }),
24
+ auth: new Modules.auth(),
25
+ actions: Modules.actions,
26
+ config: {
27
+ license: licenseKey,
28
+ status: {
29
+ name: packageJson.name,
30
+ nameVersion: packageJson.version,
31
+ version: '8.0.0'
32
+ },
33
+ auth: {
34
+ portal: get(process.env, 'PORTAL_SECRET', ''),
35
+ secret: get(process.env, 'JWT_SECRET', ''),
36
+ expire: get(process.env, 'JWT_EXPIRE_TIME', 240)
37
+ },
38
+ project: {
39
+ url: get(process.env, 'PROJECT_ENDPOINT', ''),
40
+ key: get(process.env, 'PROJECT_KEY', '')
41
+ }
42
+ }
43
+ });
44
+
45
+ // Bootup the server.
46
+ (async function bootup() {
47
+ // Initialize the server.
48
+ await server.init();
49
+
50
+ // Add the server router.
51
+ app.use(await server.router());
52
+
53
+ // Start server.
54
+ app.listen(process.env.PORT, () => {
55
+ console.log(`Server running on port ${process.env.PORT}`);
56
+ });
57
+ })();
58
+ ```
59
+
60
+ ### Configuration
61
+ The following configurations can be provided to the Server instance.
@@ -0,0 +1,160 @@
1
+ /// <reference types="express" />
2
+ declare const _default: {
3
+ save: {
4
+ readonly info: {
5
+ name: string;
6
+ title: string;
7
+ description: string;
8
+ priority: number;
9
+ defaults: {
10
+ handler: string[];
11
+ method: string[];
12
+ };
13
+ access: {
14
+ handler: boolean;
15
+ method: boolean;
16
+ };
17
+ };
18
+ mappingComponents(scope: import("../types/action").ActionScope): Promise<any>;
19
+ settingsForm(scope: import("../types/action").ActionScope): Promise<any>;
20
+ saveToForm(scope: import("../types/action").ActionScope, resource: string): undefined;
21
+ childSubmission(scope: import("../types/action").ActionScope, req: import("../types/submission").SubmissionRequest, res: import("../types/submission").SubmissionResponse, submission: any): any;
22
+ childResponse(scope: import("../types/action").ActionScope, req: import("../types/submission").SubmissionRequest, res: import("../types/submission").SubmissionResponse): void;
23
+ executor(scope: import("../types/action").ActionScope): Promise<(req: import("../types/submission").SubmissionRequest, res: import("../types/submission").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
24
+ };
25
+ login: {
26
+ readonly info: {
27
+ name: string;
28
+ title: string;
29
+ description: string;
30
+ priority: number;
31
+ defaults: {
32
+ handler: string[];
33
+ method: string[];
34
+ };
35
+ access: {
36
+ handler: boolean;
37
+ method: boolean;
38
+ };
39
+ };
40
+ settingsForm(scope: import("../types/action").ActionScope): Promise<({
41
+ type: string;
42
+ label: string;
43
+ key: string;
44
+ placeholder: string;
45
+ dataSrc: string;
46
+ valueProperty: string;
47
+ data: {
48
+ json: any;
49
+ };
50
+ multiple: boolean;
51
+ validate: {
52
+ required: boolean;
53
+ };
54
+ input?: undefined;
55
+ description?: undefined;
56
+ defaultValue?: undefined;
57
+ suffix?: undefined;
58
+ } | {
59
+ type: string;
60
+ input: boolean;
61
+ label: string;
62
+ key: string;
63
+ placeholder: string;
64
+ dataSrc: string;
65
+ valueProperty: string;
66
+ data: {
67
+ json: any;
68
+ };
69
+ multiple: boolean;
70
+ validate: {
71
+ required: boolean;
72
+ };
73
+ description?: undefined;
74
+ defaultValue?: undefined;
75
+ suffix?: undefined;
76
+ } | {
77
+ type: string;
78
+ key: string;
79
+ input: boolean;
80
+ label: string;
81
+ description: string;
82
+ defaultValue: string;
83
+ placeholder?: undefined;
84
+ dataSrc?: undefined;
85
+ valueProperty?: undefined;
86
+ data?: undefined;
87
+ multiple?: undefined;
88
+ validate?: undefined;
89
+ suffix?: undefined;
90
+ } | {
91
+ type: string;
92
+ key: string;
93
+ input: boolean;
94
+ label: string;
95
+ description: string;
96
+ defaultValue: string;
97
+ suffix: string;
98
+ placeholder?: undefined;
99
+ dataSrc?: undefined;
100
+ valueProperty?: undefined;
101
+ data?: undefined;
102
+ multiple?: undefined;
103
+ validate?: undefined;
104
+ })[]>;
105
+ waitText(time: number): string;
106
+ checkAttempts(scope: import("../types/action").ActionScope, error: any, user: import("../types/server").User): Promise<any>;
107
+ executor(scope: import("../types/action").ActionScope): Promise<(req: import("../types/submission").SubmissionRequest, res: import("../types/submission").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
108
+ };
109
+ role: {
110
+ readonly info: {
111
+ name: string;
112
+ title: string;
113
+ description: string;
114
+ priority: number;
115
+ defaults: {
116
+ handler: string[];
117
+ method: string[];
118
+ };
119
+ access: {
120
+ handler: boolean;
121
+ method: boolean;
122
+ };
123
+ };
124
+ settingsForm(scope: import("../types/action").ActionScope): Promise<({
125
+ type: string;
126
+ input: boolean;
127
+ label: string;
128
+ key: string;
129
+ placeholder: string;
130
+ template: string;
131
+ dataSrc: string;
132
+ data: {
133
+ json: string;
134
+ };
135
+ valueProperty: string;
136
+ multiple: boolean;
137
+ validate: {
138
+ required: boolean;
139
+ };
140
+ } | {
141
+ type: string;
142
+ input: boolean;
143
+ label: string;
144
+ key: string;
145
+ placeholder: string;
146
+ template: string;
147
+ dataSrc: string;
148
+ data: {
149
+ json: unknown[];
150
+ };
151
+ valueProperty: string;
152
+ multiple: boolean;
153
+ validate: {
154
+ required: boolean;
155
+ };
156
+ })[]>;
157
+ executor(scope: import("../types/action").ActionScope): Promise<(req: import("../types/submission").SubmissionRequest, res: import("../types/submission").SubmissionResponse, next: import("express").NextFunction) => Promise<void | import("../types/submission").SubmissionResponse>>;
158
+ };
159
+ };
160
+ export default _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const LoginAction_1 = require("./login/LoginAction");
4
+ const RoleAction_1 = require("./role/RoleAction");
5
+ const SaveAction_1 = require("./save/SaveAction");
6
+ exports.default = {
7
+ save: SaveAction_1.SaveAction,
8
+ login: LoginAction_1.LoginAction,
9
+ role: RoleAction_1.RoleAction
10
+ };
@@ -0,0 +1,110 @@
1
+ import { ActionScope } from '../../types/action';
2
+ import { User } from '../../types/server';
3
+ import { SubmissionRequest, SubmissionResponse } from 'src/types/submission';
4
+ import { NextFunction } from 'express';
5
+ export declare const LoginAction: {
6
+ readonly info: {
7
+ name: string;
8
+ title: string;
9
+ description: string;
10
+ priority: number;
11
+ defaults: {
12
+ handler: string[];
13
+ method: string[];
14
+ };
15
+ access: {
16
+ handler: boolean;
17
+ method: boolean;
18
+ };
19
+ };
20
+ /**
21
+ * The settings form for this action.
22
+ * @param {*} scope
23
+ */
24
+ settingsForm(scope: ActionScope): Promise<({
25
+ type: string;
26
+ label: string;
27
+ key: string;
28
+ placeholder: string;
29
+ dataSrc: string;
30
+ valueProperty: string;
31
+ data: {
32
+ json: any;
33
+ };
34
+ multiple: boolean;
35
+ validate: {
36
+ required: boolean;
37
+ };
38
+ input?: undefined;
39
+ description?: undefined;
40
+ defaultValue?: undefined;
41
+ suffix?: undefined;
42
+ } | {
43
+ type: string;
44
+ input: boolean;
45
+ label: string;
46
+ key: string;
47
+ placeholder: string;
48
+ dataSrc: string;
49
+ valueProperty: string;
50
+ data: {
51
+ json: any;
52
+ };
53
+ multiple: boolean;
54
+ validate: {
55
+ required: boolean;
56
+ };
57
+ description?: undefined;
58
+ defaultValue?: undefined;
59
+ suffix?: undefined;
60
+ } | {
61
+ type: string;
62
+ key: string;
63
+ input: boolean;
64
+ label: string;
65
+ description: string;
66
+ defaultValue: string;
67
+ placeholder?: undefined;
68
+ dataSrc?: undefined;
69
+ valueProperty?: undefined;
70
+ data?: undefined;
71
+ multiple?: undefined;
72
+ validate?: undefined;
73
+ suffix?: undefined;
74
+ } | {
75
+ type: string;
76
+ key: string;
77
+ input: boolean;
78
+ label: string;
79
+ description: string;
80
+ defaultValue: string;
81
+ suffix: string;
82
+ placeholder?: undefined;
83
+ dataSrc?: undefined;
84
+ valueProperty?: undefined;
85
+ data?: undefined;
86
+ multiple?: undefined;
87
+ validate?: undefined;
88
+ })[]>;
89
+ /**
90
+ * Format a string to show how long one must wait.
91
+ *
92
+ * @param time - In seconds.
93
+ * @returns {string}
94
+ */
95
+ waitText(time: number): string;
96
+ /**
97
+ * Checks the login attempts for a certain login.
98
+ *
99
+ * @param user
100
+ * @param next
101
+ * @returns {*}
102
+ */
103
+ checkAttempts(scope: ActionScope, error: any, user: User): Promise<any>;
104
+ /**
105
+ * Returns the action middleware.
106
+ *
107
+ * @param {*} scope
108
+ */
109
+ executor(scope: ActionScope): Promise<(req: SubmissionRequest, res: SubmissionResponse, next: NextFunction) => Promise<void>>;
110
+ };
@@ -0,0 +1,288 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LoginAction = void 0;
16
+ const bcryptjs_1 = __importDefault(require("bcryptjs"));
17
+ const has_1 = __importDefault(require("lodash/has"));
18
+ const set_1 = __importDefault(require("lodash/set"));
19
+ const get_1 = __importDefault(require("lodash/get"));
20
+ const unset_1 = __importDefault(require("lodash/unset"));
21
+ const debug = require('debug')('formio:action:login');
22
+ const error = require('debug')('formio:error');
23
+ exports.LoginAction = {
24
+ // The action information.
25
+ get info() {
26
+ return {
27
+ name: 'login',
28
+ title: 'Login',
29
+ description: 'Provides a way to login to the application.',
30
+ priority: 2,
31
+ defaults: {
32
+ handler: ['before'],
33
+ method: ['create'],
34
+ },
35
+ access: {
36
+ handler: false,
37
+ method: false,
38
+ },
39
+ };
40
+ },
41
+ /**
42
+ * The settings form for this action.
43
+ * @param {*} scope
44
+ */
45
+ settingsForm(scope) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const fields = [];
48
+ const resources = [];
49
+ for (let name in scope.template.resources) {
50
+ const resource = scope.template.resources[name];
51
+ resources.push({
52
+ label: resource.title,
53
+ value: resource.name
54
+ });
55
+ }
56
+ scope.utils.eachComponent(scope.form.components, (component) => {
57
+ if (['button'].indexOf(component.type) !== -1) {
58
+ return;
59
+ }
60
+ fields.push({
61
+ label: component.label || component.key,
62
+ value: component.key
63
+ });
64
+ });
65
+ return [
66
+ {
67
+ type: 'select',
68
+ label: 'Resources',
69
+ key: 'resources',
70
+ placeholder: 'Select the resources we should login against.',
71
+ dataSrc: 'json',
72
+ valueProperty: 'value',
73
+ data: { json: resources },
74
+ multiple: true,
75
+ validate: {
76
+ required: true,
77
+ },
78
+ },
79
+ {
80
+ type: 'select',
81
+ input: true,
82
+ label: 'Username Field',
83
+ key: 'username',
84
+ placeholder: 'Select the username field',
85
+ dataSrc: 'json',
86
+ valueProperty: 'value',
87
+ data: { json: fields },
88
+ multiple: false,
89
+ validate: {
90
+ required: true,
91
+ },
92
+ },
93
+ {
94
+ type: 'select',
95
+ label: 'Password Field',
96
+ key: 'password',
97
+ placeholder: 'Select the password field',
98
+ dataSrc: 'json',
99
+ valueProperty: 'value',
100
+ data: { json: fields },
101
+ multiple: false,
102
+ validate: {
103
+ required: true,
104
+ },
105
+ },
106
+ {
107
+ type: 'textfield',
108
+ key: 'allowedAttempts',
109
+ input: true,
110
+ label: 'Maximum Login Attempts',
111
+ description: 'Use 0 for unlimited attempts',
112
+ defaultValue: '5',
113
+ },
114
+ {
115
+ type: 'textfield',
116
+ key: 'attemptWindow',
117
+ input: true,
118
+ label: 'Login Attempt Time Window',
119
+ description: 'This is the window of time to count the login attempts.',
120
+ defaultValue: '30',
121
+ suffix: 'seconds',
122
+ },
123
+ {
124
+ type: 'textfield',
125
+ key: 'lockWait',
126
+ input: true,
127
+ label: 'Locked Account Wait Time',
128
+ description: 'The amount of time a person needs to wait before they can try to login again.',
129
+ defaultValue: '1800',
130
+ suffix: 'seconds',
131
+ },
132
+ ];
133
+ });
134
+ },
135
+ /**
136
+ * Format a string to show how long one must wait.
137
+ *
138
+ * @param time - In seconds.
139
+ * @returns {string}
140
+ */
141
+ waitText(time) {
142
+ return (time > 60) ? `${(time / 60)} minutes` : `${time} seconds`;
143
+ },
144
+ /**
145
+ * Checks the login attempts for a certain login.
146
+ *
147
+ * @param user
148
+ * @param next
149
+ * @returns {*}
150
+ */
151
+ checkAttempts(scope, error, user) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ const action = scope.action;
154
+ if (!user || !user._id || !action.settings.allowedAttempts) {
155
+ return;
156
+ }
157
+ const allowedAttempts = parseInt(action.settings.allowedAttempts, 10);
158
+ if (Number.isNaN(allowedAttempts) || allowedAttempts === 0) {
159
+ return;
160
+ }
161
+ // Initialize the login metadata.
162
+ if (!(0, has_1.default)(user, 'metadata.login')) {
163
+ (0, set_1.default)(user, 'metadata.login', {});
164
+ }
165
+ const now = (new Date()).getTime();
166
+ const { login: loginMetadata, } = user.metadata;
167
+ const lastAttempt = parseInt(loginMetadata.last, 10) || 0;
168
+ // See if the login is locked.
169
+ if (loginMetadata.locked) {
170
+ // Get how long they must wait to be locked out.
171
+ let lockWait = parseInt(action.settings.lockWait, 10) || 1800;
172
+ // Normalize to milliseconds.
173
+ lockWait *= 1000;
174
+ // See if the time has expired.
175
+ if ((lastAttempt + lockWait) < now) {
176
+ // Reset the locked state and attempts totals.
177
+ loginMetadata.attempts = 0;
178
+ loginMetadata.locked = false;
179
+ loginMetadata.last = now;
180
+ }
181
+ else {
182
+ const howLong = (lastAttempt + lockWait) - now;
183
+ return `You must wait ${exports.LoginAction.waitText(howLong / 1000)} before you can login.`;
184
+ }
185
+ }
186
+ else if (error) {
187
+ let attemptWindow = parseInt(action.settings.attemptWindow, 10) || 30;
188
+ // Normalize to milliseconds.
189
+ attemptWindow *= 1000;
190
+ // Determine the login attempts within a certain window.
191
+ const withinWindow = lastAttempt ? ((lastAttempt + attemptWindow) > now) : false;
192
+ if (withinWindow) {
193
+ const attempts = (parseInt(loginMetadata.attempts, 10) || 0) + 1;
194
+ // If they exceeded the login attempts.
195
+ if (attempts >= allowedAttempts) {
196
+ const lockWait = parseInt(action.settings.lockWait, 10) || 1800;
197
+ error = `Maximum Login attempts. Please wait ${exports.LoginAction.waitText(lockWait)} before trying again.`;
198
+ loginMetadata.locked = true;
199
+ }
200
+ // Set the login attempts.
201
+ loginMetadata.attempts = attempts;
202
+ }
203
+ else {
204
+ loginMetadata.attempts = 0;
205
+ loginMetadata.last = now;
206
+ }
207
+ }
208
+ else {
209
+ // If there was no error, then reset the attempts to zero.
210
+ loginMetadata.attempts = 0;
211
+ loginMetadata.last = now;
212
+ }
213
+ // Update the user record
214
+ yield scope.db.update(scope, user._id.toString(), user);
215
+ return error;
216
+ });
217
+ },
218
+ /**
219
+ * Returns the action middleware.
220
+ *
221
+ * @param {*} scope
222
+ */
223
+ executor(scope) {
224
+ return __awaiter(this, void 0, void 0, function* () {
225
+ const action = scope.action;
226
+ const userfield = action.settings.username;
227
+ const passfield = action.settings.password;
228
+ const forms = yield scope.utils.getForms(scope, action.settings.resources);
229
+ return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
230
+ var _a, _b;
231
+ debug('Login Action');
232
+ const username = (0, get_1.default)((_a = req.body) === null || _a === void 0 ? void 0 : _a.data, userfield);
233
+ const password = (0, get_1.default)((_b = req.body) === null || _b === void 0 ? void 0 : _b.data, passfield);
234
+ if (!username) {
235
+ error('Missing username');
236
+ return next('Missing username');
237
+ }
238
+ if (!password) {
239
+ error('Missing password');
240
+ return next('Missing password');
241
+ }
242
+ // Find the user
243
+ debug('Finding user', `${userfield} = ${username}`);
244
+ const user = yield scope.utils.findUser(scope, forms, `data.${userfield}`, username);
245
+ if (!user) {
246
+ error('User not found');
247
+ return next('User or password was incorrect');
248
+ }
249
+ // Get the current password hash.
250
+ const hash = (0, get_1.default)(user.data, passfield);
251
+ if (!hash || !hash.hash) {
252
+ error('User does not have a password');
253
+ return next('Your account does not have a password. You must reset your password to login.');
254
+ }
255
+ // Compare with bcrypt.
256
+ debug('Comparing password');
257
+ bcryptjs_1.default.compare(password, hash.hash, (err, value) => __awaiter(this, void 0, void 0, function* () {
258
+ if (err) {
259
+ error(err);
260
+ return next(err);
261
+ }
262
+ // Check the login attempts.
263
+ const errorAttempts = yield exports.LoginAction.checkAttempts(scope, !value, user);
264
+ if (errorAttempts) {
265
+ error(errorAttempts);
266
+ return next(errorAttempts === true ? 'User or password was incorrect' : errorAttempts);
267
+ }
268
+ // Unset the password field before we create a token from it.
269
+ (0, unset_1.default)(user.data, passfield);
270
+ // Set the user object.
271
+ req.user = user;
272
+ req.token = yield scope.auth.token(scope.utils.tokenFromUser(user), scope.config.auth.secret, scope.config.auth.expire);
273
+ // Set the auth headers.
274
+ res.setHeader('x-jwt-token', req.token);
275
+ req.headers['x-jwt-token'] = req.token;
276
+ if (res.resource) {
277
+ res.resource.item = req.user;
278
+ }
279
+ else {
280
+ res.resource = { status: 200, item: req.user };
281
+ }
282
+ debug('Login Successful', req.user);
283
+ next();
284
+ }));
285
+ });
286
+ });
287
+ }
288
+ };
@@ -0,0 +1,62 @@
1
+ import { SubmissionRequest, SubmissionResponse } from "src/types/submission";
2
+ import { ActionScope } from "../../types/action";
3
+ import { NextFunction } from "express";
4
+ export declare const RoleAction: {
5
+ readonly info: {
6
+ name: string;
7
+ title: string;
8
+ description: string;
9
+ priority: number;
10
+ defaults: {
11
+ handler: string[];
12
+ method: string[];
13
+ };
14
+ access: {
15
+ handler: boolean;
16
+ method: boolean;
17
+ };
18
+ };
19
+ /**
20
+ * The settings form for this action.
21
+ * @param {*} scope
22
+ */
23
+ settingsForm(scope: ActionScope): Promise<({
24
+ type: string;
25
+ input: boolean;
26
+ label: string;
27
+ key: string;
28
+ placeholder: string;
29
+ template: string;
30
+ dataSrc: string;
31
+ data: {
32
+ json: string;
33
+ };
34
+ valueProperty: string;
35
+ multiple: boolean;
36
+ validate: {
37
+ required: boolean;
38
+ };
39
+ } | {
40
+ type: string;
41
+ input: boolean;
42
+ label: string;
43
+ key: string;
44
+ placeholder: string;
45
+ template: string;
46
+ dataSrc: string;
47
+ data: {
48
+ json: unknown[];
49
+ };
50
+ valueProperty: string;
51
+ multiple: boolean;
52
+ validate: {
53
+ required: boolean;
54
+ };
55
+ })[]>;
56
+ /**
57
+ * Returns the action middleware.
58
+ *
59
+ * @param {*} scope
60
+ */
61
+ executor(scope: ActionScope): Promise<(req: SubmissionRequest, res: SubmissionResponse, next: NextFunction) => Promise<void | SubmissionResponse>>;
62
+ };