dvAdminFor function

DVAdminRequest dvAdminFor(
  1. String path,
  2. DVAdminMount mount, {
  3. required bool authenticated,
})

What the backend should do with path.

authenticated is the caller's state as the application's own auth decided it -- this does not authenticate anybody, it decides what an already-known answer means for this route.

Implementation

DVAdminRequest dvAdminFor(
  String path,
  DVAdminMount mount, {
  required bool authenticated,
}) {
  // The mount, not the default path. A project that moved its admin
  // somewhere private must not lose the check by doing so.
  if (!mount.owns(path)) return DVAdminRequest.notTheAdmin;
  if (!mount.enabled) return DVAdminRequest.hidden;
  if (mount.requiresAuth && !authenticated) return DVAdminRequest.hidden;
  return DVAdminRequest.serve;
}