Skip to content

AuthorizationExtensions.ValidatePermission method

Ensures the current user has the specified permission, throwing a validation error with code AccessDenied otherwise.

public static void ValidatePermission(this IPermissionService permissions, string permission, 
    ITextLocalizer localizer)
parameter description
permissions The permission service to query.
permission The required permission key.
localizer The localizer used to produce the error message.

Exceptions

exception condition
ArgumentNullException permissions is null.
ValidationError The current user does not have the required permission.

See Also