Skip to content

Commit

Permalink
fix: do not prompt for connections in-game
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Nov 18, 2023
1 parent 7180dac commit 3cd268b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}
},
"rules": {
"capitalized-comments": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
Expand Down
4 changes: 4 additions & 0 deletions apps/client/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export function formatOfficerDepartment(unit: Officer | EmsFdDeputy) {
return getUnitDepartment(unit)?.value.value ?? null;
}

/**
* Check if a user can use third party connections. It will check if the user is inside of an iframe.
* @returns {boolean}
*/
export function canUseThirdPartyConnections() {
if (typeof window === "undefined") return true;
return window.location === window.parent.location;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Feature, Rank, type User } from "@snailycad/types";
import { DEFAULT_DISABLED_FEATURES } from "hooks/useFeatureEnabled";
import { canUseThirdPartyConnections } from "lib/utils";

interface VerifyUserConnectionsOptions {
user: User;
Expand All @@ -11,8 +12,13 @@ export function doesUserHaveAllRequiredConnections(options: VerifyUserConnection
const discordId = options.user.discordId;
const isOwner = options.user.rank === Rank.OWNER;

// Owner does not require to have all connections
if (isOwner) {
// owner does not require to have all connections
return true;
}

// We cannot ask the user to connect to a third party if they're inside of an iframe.
if (!canUseThirdPartyConnections()) {
return true;
}

Expand Down

0 comments on commit 3cd268b

Please sign in to comment.