🚨 Announcement: A New Chapter for Vendure read more

OrderByCodeAccessStrategy

OrderByCodeAccessStrategy

The OrderByCodeAccessStrategy determines how access to a placed Order via the orderByCode query is granted. With a custom strategy anonymous access could be made permanent or tied to specific conditions like IP range or an Order status.

Example

This example grants access to the requested Order to anyone – unless it’s Monday.

export class NotMondayOrderByCodeAccessStrategy implements OrderByCodeAccessStrategy {
    canAccessOrder(ctx: RequestContext, order: Order): boolean {
        const MONDAY = 1;
        const today = (new Date()).getDay();

        return today !== MONDAY;
    }
}

Signature

interface OrderByCodeAccessStrategy extends InjectableStrategy {
  canAccessOrder(ctx: RequestContext, order: Order): boolean | Promise<boolean>;
}

Extends

Members

canAccessOrder

method
type:
(ctx: RequestContext, order: Order) => boolean | Promise<boolean>
Gives or denies permission to access the requested Order

DefaultOrderByCodeAccessStrategy

The default OrderByCodeAccessStrategy used by Vendure. It permitts permanent access to the Customer owning the Order and anyone within a given time period after placing the Order (defaults to 2h).

Signature

class DefaultOrderByCodeAccessStrategy implements OrderByCodeAccessStrategy {
  constructor(anonymousAccessDuration: string)
  canAccessOrder(ctx: RequestContext, order: Order) => boolean;
}

Implements

Members

constructor

method
type:
(anonymousAccessDuration: string) => DefaultOrderByCodeAccessStrategy

canAccessOrder

method
type:
(ctx: RequestContext, order: Order) => boolean