Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+5
-1
@@ -9,11 +9,11 @@
|
||||
// block the connect.
|
||||
|
||||
import { decryptTenantField, encryptTenantField } from "@hivegrid/db/crypto/tenant-envelope.server";
|
||||
import { getRlsExecutionContext } from "@hivegrid/db/rls-context.server";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { googleCalendarAdapter, CalendarNotConfiguredError } from "./adapters/GoogleCalendarAdapter.server";
|
||||
import type { CalendarCreds } from "./adapters/CalendarAdapter";
|
||||
import { signCalendarOAuthState, verifyCalendarOAuthState } from "./oauthState.server";
|
||||
import { GOOGLE_OAUTH_CALLBACK_PATH } from "../routes/calendarRoutePaths";
|
||||
|
||||
export class CalendarConnectError extends Error {
|
||||
readonly code: "not_configured" | "invalid_state" | "exchange_failed";
|
||||
@@ -45,6 +45,10 @@ export async function completeOAuthCallback(input: { code: string; state: string
|
||||
throw new CalendarConnectError("invalid_state");
|
||||
}
|
||||
const { tenantId, userId, tenantSlug } = verified.payload;
|
||||
const rlsContext = getRlsExecutionContext();
|
||||
if (rlsContext?.tenantId !== tenantId || rlsContext.userId !== userId) {
|
||||
throw new CalendarConnectError("invalid_state");
|
||||
}
|
||||
|
||||
let exchange: Awaited<ReturnType<typeof googleCalendarAdapter.exchangeCode>>;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user