All files / realm/blong-access/gateway/access accessProfileGet.ts

100% Statements 56/56
100% Branches 2/2
100% Functions 1/1
100% Lines 56/56

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 571x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 1x  
import {validation} from '@feasibleone/blong';
 
/**
 * Protected RPC endpoint returning the authenticated user's own profile:
 * account details (username, email, active flag), the persisted preferred
 * language, the granted roles and — when available — the linked party.person.
 *
 * Self-service: bearer-authenticated but no RBAC action needed (`skipAuthorize`
 * — the actor id comes from the token's `sub` claim, never from params).
 */
export default validation(
    async ({lib: {type}}) =>
        function accessProfileGet() {
            return {
                skipAuthorize: true,
                params: type.Object({}),
                result: type.Object(
                    {
                        userId: type.String(),
                        userName: type.Union([type.String(), type.Null()]),
                        emailAddress: type.Union([type.String(), type.Null()]),
                        isActive: type.Boolean(),
                        preferredLanguage: type.Union([type.String(), type.Null()]),
                        roles: type.Array(
                            type.Object(
                                {
                                    roleId: type.String(),
                                    roleName: type.String(),
                                },
                                {additionalProperties: true},
                            ),
                        ),
                        person: type.Optional(
                            type.Object(
                                {
                                    personId: type.String(),
                                    firstName: type.String(),
                                    middleName: type.Union([type.String(), type.Null()]),
                                    lastName: type.String(),
                                    birthDate: type.Union([type.String(), type.Null()]),
                                    gender: type.Union([type.String(), type.Null()]),
                                    nationality: type.Union([type.String(), type.Null()]),
                                    occupation: type.Union([type.String(), type.Null()]),
                                    photoUrl: type.Optional(
                                        type.Union([type.String(), type.Null()]),
                                    ),
                                },
                                {additionalProperties: true},
                            ),
                        ),
                    },
                    {additionalProperties: true},
                ),
            };
        },
);