@aeriajs/builtins 0.0.186 → 0.0.187
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.
|
@@ -6,6 +6,16 @@ export declare enum ActivationError {
|
|
|
6
6
|
InvalidLink = "INVALID_LINK"
|
|
7
7
|
}
|
|
8
8
|
export declare const getCurrentUser: (_payload: undefined, context: Context<typeof description>) => Promise<{
|
|
9
|
+
readonly _tag: "Result";
|
|
10
|
+
readonly error: undefined;
|
|
11
|
+
readonly result: {
|
|
12
|
+
_id: null;
|
|
13
|
+
name: string;
|
|
14
|
+
email: string;
|
|
15
|
+
roles: string[];
|
|
16
|
+
active: boolean;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
9
19
|
readonly _tag: "Result";
|
|
10
20
|
readonly error: undefined;
|
|
11
21
|
readonly result: import("@aeriajs/types").SchemaWithId<{
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentUser = exports.ActivationError = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
|
+
const authentication_js_1 = require("../../authentication.js");
|
|
5
6
|
var ActivationError;
|
|
6
7
|
(function (ActivationError) {
|
|
7
8
|
ActivationError["UserNotFound"] = "USER_NOT_FOUND";
|
|
@@ -12,6 +13,10 @@ const getCurrentUser = async (_payload, context) => {
|
|
|
12
13
|
if (!context.token.authenticated) {
|
|
13
14
|
throw new Error();
|
|
14
15
|
}
|
|
16
|
+
if (!context.token.sub) {
|
|
17
|
+
const { user } = await (0, authentication_js_1.defaultSuccessfulAuthentication)();
|
|
18
|
+
return types_1.Result.result(user);
|
|
19
|
+
}
|
|
15
20
|
const { error, result: user } = await context.collections.user.functions.get({
|
|
16
21
|
filters: {
|
|
17
22
|
_id: context.token.sub,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { Result } from "@aeriajs/types";
|
|
3
|
+
import { defaultSuccessfulAuthentication } from "../../authentication.mjs";
|
|
3
4
|
export var ActivationError = /* @__PURE__ */ ((ActivationError2) => {
|
|
4
5
|
ActivationError2["UserNotFound"] = "USER_NOT_FOUND";
|
|
5
6
|
ActivationError2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
|
|
@@ -10,6 +11,10 @@ export const getCurrentUser = async (_payload, context) => {
|
|
|
10
11
|
if (!context.token.authenticated) {
|
|
11
12
|
throw new Error();
|
|
12
13
|
}
|
|
14
|
+
if (!context.token.sub) {
|
|
15
|
+
const { user: user2 } = await defaultSuccessfulAuthentication();
|
|
16
|
+
return Result.result(user2);
|
|
17
|
+
}
|
|
13
18
|
const { error, result: user } = await context.collections.user.functions.get({
|
|
14
19
|
filters: {
|
|
15
20
|
_id: context.token.sub
|
|
@@ -449,6 +449,16 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
449
449
|
};
|
|
450
450
|
}>;
|
|
451
451
|
getCurrentUser: (_payload: undefined, context: import("@aeriajs/types").Context<typeof description>) => Promise<{
|
|
452
|
+
readonly _tag: "Result";
|
|
453
|
+
readonly error: undefined;
|
|
454
|
+
readonly result: {
|
|
455
|
+
_id: null;
|
|
456
|
+
name: string;
|
|
457
|
+
email: string;
|
|
458
|
+
roles: string[];
|
|
459
|
+
active: boolean;
|
|
460
|
+
};
|
|
461
|
+
} | {
|
|
452
462
|
readonly _tag: "Result";
|
|
453
463
|
readonly error: undefined;
|
|
454
464
|
readonly result: import("@aeriajs/types").SchemaWithId<{
|
package/dist/index.d.ts
CHANGED
|
@@ -878,6 +878,16 @@ export declare const collections: {
|
|
|
878
878
|
};
|
|
879
879
|
}>;
|
|
880
880
|
getCurrentUser: (_payload: undefined, context: import("@aeriajs/types").Context<typeof import("./collections/user/description.js").description>) => Promise<{
|
|
881
|
+
readonly _tag: "Result";
|
|
882
|
+
readonly error: undefined;
|
|
883
|
+
readonly result: {
|
|
884
|
+
_id: null;
|
|
885
|
+
name: string;
|
|
886
|
+
email: string;
|
|
887
|
+
roles: string[];
|
|
888
|
+
active: boolean;
|
|
889
|
+
};
|
|
890
|
+
} | {
|
|
881
891
|
readonly _tag: "Result";
|
|
882
892
|
readonly error: undefined;
|
|
883
893
|
readonly result: import("@aeriajs/types").SchemaWithId<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/builtins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.187",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"mongodb": "^6.5.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@aeriajs/core": "^0.0.
|
|
48
|
+
"@aeriajs/core": "^0.0.187",
|
|
49
49
|
"@aeriajs/common": "^0.0.114",
|
|
50
50
|
"@aeriajs/entrypoint": "^0.0.117",
|
|
51
51
|
"@aeriajs/types": "^0.0.97",
|