@aeriajs/builtins 0.0.285 → 0.0.286
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineContract, HTTPStatus, ACError, functionSchemas, endpointErrorSchema, resultSchema } from '@aeriajs/types';
|
|
2
|
-
import { validate } from '@aeriajs/validation';
|
|
3
2
|
import * as bcrypt from 'bcryptjs';
|
|
4
3
|
import { insert as originalInsert } from '@aeriajs/core';
|
|
5
4
|
import { description } from './description.js';
|
|
@@ -32,36 +31,12 @@ export const createAccountContract = defineContract({
|
|
|
32
31
|
],
|
|
33
32
|
});
|
|
34
33
|
export const createAccount = async (payload, context) => {
|
|
35
|
-
const userCandidate = Object.assign({}, payload);
|
|
36
34
|
if (!context.config.security.signup) {
|
|
37
35
|
return context.error(HTTPStatus.Forbidden, {
|
|
38
36
|
code: CreateAccountError.SignupDisallowed,
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
|
-
const
|
|
42
|
-
type: 'object',
|
|
43
|
-
required: [
|
|
44
|
-
'name',
|
|
45
|
-
'email',
|
|
46
|
-
],
|
|
47
|
-
properties: {
|
|
48
|
-
name: {
|
|
49
|
-
type: 'string',
|
|
50
|
-
},
|
|
51
|
-
email: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
},
|
|
54
|
-
password: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
if (error) {
|
|
60
|
-
return context.error(HTTPStatus.UnprocessableContent, {
|
|
61
|
-
code: ACError.MalformedInput,
|
|
62
|
-
details: error,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
39
|
+
const user = payload;
|
|
65
40
|
const { roles, ...defaults } = context.config.security.signup;
|
|
66
41
|
if (user.password) {
|
|
67
42
|
user.password = await bcrypt.hash(user.password, 10);
|
|
@@ -32,7 +32,7 @@ export declare const describe: (contextOrPayload: RouteContext | typeof Payload)
|
|
|
32
32
|
readonly error: {
|
|
33
33
|
readonly httpStatus: 422;
|
|
34
34
|
readonly code: "MALFORMED_INPUT";
|
|
35
|
-
readonly details: import("@aeriajs/types").
|
|
35
|
+
readonly details: import("@aeriajs/types").ValidationError | import("@aeriajs/types").PropertyValidationError;
|
|
36
36
|
};
|
|
37
37
|
readonly result: undefined;
|
|
38
38
|
} | {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/builtins",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.286",
|
|
5
5
|
"description": "## Installation",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@aeriajs/common": "^0.0.161",
|
|
45
|
-
"@aeriajs/core": "^0.0.
|
|
45
|
+
"@aeriajs/core": "^0.0.286",
|
|
46
46
|
"@aeriajs/entrypoint": "^0.0.169",
|
|
47
47
|
"@aeriajs/types": "^0.0.137",
|
|
48
48
|
"@aeriajs/validation": "^0.0.185"
|