mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-04 17:56:38 +00:00
Returning unauthorized
This commit is contained in:
@@ -33,9 +33,7 @@ import createHttpError from "http-errors";
|
|||||||
import NodeCache from "node-cache";
|
import NodeCache from "node-cache";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import {
|
import { getCountryCodeForIp } from "@server/lib/geoip";
|
||||||
getCountryCodeForIp,
|
|
||||||
} from "@server/lib/geoip";
|
|
||||||
import { getOrgTierData } from "#dynamic/lib/billing";
|
import { getOrgTierData } from "#dynamic/lib/billing";
|
||||||
import { TierId } from "@server/lib/billing/tiers";
|
import { TierId } from "@server/lib/billing/tiers";
|
||||||
import { verifyPassword } from "@server/auth/password";
|
import { verifyPassword } from "@server/auth/password";
|
||||||
@@ -198,7 +196,7 @@ export async function verifyResourceSession(
|
|||||||
|
|
||||||
// IMPORTANT: ADD NEW AUTH CHECKS HERE OR WHEN TURNING OFF ALL OTHER AUTH METHODS IT WILL JUST PASS
|
// IMPORTANT: ADD NEW AUTH CHECKS HERE OR WHEN TURNING OFF ALL OTHER AUTH METHODS IT WILL JUST PASS
|
||||||
if (
|
if (
|
||||||
!resource.sso &&
|
!sso &&
|
||||||
!pincode &&
|
!pincode &&
|
||||||
!password &&
|
!password &&
|
||||||
!resource.emailWhitelistEnabled &&
|
!resource.emailWhitelistEnabled &&
|
||||||
@@ -315,8 +313,22 @@ export async function verifyResourceSession(
|
|||||||
return allowed(res);
|
return allowed(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are no other auth methods we need to return unauthorized here
|
if ( // we dont want to redirect if this is the only auth method and we did not pass here
|
||||||
if (!sso && !pincode && !password && !resource.emailWhitelistEnabled) {
|
!sso &&
|
||||||
|
!pincode &&
|
||||||
|
!password &&
|
||||||
|
!resource.emailWhitelistEnabled
|
||||||
|
) {
|
||||||
|
return notAllowed(res);
|
||||||
|
}
|
||||||
|
} else if (headerAuth) {
|
||||||
|
// if there are no other auth methods we need to return unauthorized if nothing is provided
|
||||||
|
if (
|
||||||
|
!sso &&
|
||||||
|
!pincode &&
|
||||||
|
!password &&
|
||||||
|
!resource.emailWhitelistEnabled
|
||||||
|
) {
|
||||||
return notAllowed(res);
|
return notAllowed(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user