Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(policy): redirect user who is not permitted to access by kind
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Nov 22, 2022
1 parent 161c488 commit c8b202d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/policies/kind-based.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import type { AuthenticatedRequest } from "!/types/dependent"
import type { DeserializedUserProfile } from "$/types/documents/user"
import type { AdvanceAuthenticationOptions } from "!/types/independent"

import { HOME } from "$/constants/template_page_paths"

import deserialize from "$/object/deserialize"
import AuthorizationError from "$!/errors/authorization"
import AuthenticationBasedPolicy from "!/policies/authentication-based"


/**
* Creates middleware to only allow certain kinds of user.
*
Expand Down Expand Up @@ -45,7 +46,7 @@ export default class <
const { kind } = user.data

if (!this.kinds.includes(kind)) {
throw new AuthorizationError("Correct user kind can invoke the action.")
throw new AuthorizationError("Correct user kind can invoke the action.", HOME)
}

await this.checkOthers(request)
Expand Down

0 comments on commit c8b202d

Please sign in to comment.