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

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

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 331x 1x 1x 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 1x  
import {validation} from '@feasibleone/blong';
 
/**
 * `access.profile.edit` — update the caller's own profile (email, preferred
 * language, name fields and the photograph). The actor id comes from the
 * token's `sub` claim, never from params, so this is a self-service method:
 * bearer-authenticated but no RBAC action needed.
 *
 * The name fields reach a `party.person`, and an account that has none yet gets
 * one created from the first edit that carries both names — see the adapter
 * handler, which makes the call through the party realm.
 */
export default validation(
    async ({lib: {type}}) =>
        function accessProfileEdit() {
            return {
                skipAuthorize: true,
                params: type.Object(
                    {
                        firstName: type.Optional(type.Union([type.String(), type.Null()])),
                        middleName: type.Optional(type.Union([type.String(), type.Null()])),
                        lastName: type.Optional(type.Union([type.String(), type.Null()])),
                        photoUrl: type.Optional(type.Union([type.String(), type.Null()])),
                        emailAddress: type.Optional(type.Union([type.String(), type.Null()])),
                        preferredLanguage: type.Optional(type.Union([type.String(), type.Null()])),
                    },
                    {additionalProperties: true},
                ),
                result: type.Object({success: type.Boolean()}, {additionalProperties: true}),
            };
        },
);