Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions apps/docs/get-started/create-aws-credentials.mdx

This file was deleted.

15 changes: 13 additions & 2 deletions apps/web/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ import { getServerAuthSession } from "~/server/auth";
import LoginPage from "./login-page";
import { getProviders } from "next-auth/react";

export default async function Login() {
const session = await getServerAuthSession();
export default async function Login({
searchParams,
}: {
searchParams: Promise<{ error?: string }>;
}) {
const [session, params] = await Promise.all([
getServerAuthSession(),
searchParams,
]);

if (session) {
redirect("/dashboard");
}

if (params.error === "banned") {
redirect("/banned");
}

const providers = await getProviders();

return <LoginPage providers={Object.values(providers ?? {})} />;
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/server/api/routers/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { isCloud } from "~/utils/common";
import { toPlainHtml } from "~/server/utils/email-content";
import { Target } from "lucide-react";
import { createCheckoutSessionForTeam, type CheckoutPlan } from "~/server/billing/payments";
import { TeamService } from "~/server/service/team-service";

const userAdminSelection = {
id: true,
Expand Down Expand Up @@ -459,6 +460,8 @@ export const adminRouter = createTRPCRouter({
select: teamAdminSelection,
});

await TeamService.invalidateTeamCache(teamId);

return updatedTeam;
}),

Expand Down Expand Up @@ -499,6 +502,7 @@ export const adminRouter = createTRPCRouter({
},
select: teamAdminSelection,
});
await TeamService.invalidateTeamCache(teamId);
logger.info(
{ teamId, plan, method: "complimentary" },
"[AdminRouter]: Plan assigned complimentarily",
Expand Down
8 changes: 8 additions & 0 deletions apps/web/src/server/public-api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ export const getTeamFromToken = async (c: Context) => {
});
}

// Block API access if the team is blocked
if (team.isBlocked) {
throw new ByteSendApiError({
code: "FORBIDDEN",
message: "This team has been blocked. Please contact support via Discord: https://discord.com/invite/BU8n8pJv8S",
});
}

// Block API access if any admin on the team is banned
const bannedAdmin = await db.teamUser.findFirst({
where: {
Expand Down
22 changes: 11 additions & 11 deletions apps/web/src/server/service/limit-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,9 @@ export class LimitService {
reason?: LimitReason;
available?: number;
}> {
// Limits only apply in cloud mode
if (!env.NEXT_PUBLIC_IS_CLOUD) {
return { isLimitReached: false, limit: -1 };
}

// Admin/founder teams have no limits
if (await LimitService.isAdminOrFounderTeam(teamId)) {
return { isLimitReached: false, limit: -1 };
}

// Block flag enforced in all deployment modes
const team = await TeamService.getTeamCached(teamId);

// In cloud, enforce verification and block flags first
if (team.isBlocked) {
return {
isLimitReached: true,
Expand All @@ -313,6 +303,16 @@ export class LimitService {
};
}

// Remaining limits only apply in cloud mode
if (!env.NEXT_PUBLIC_IS_CLOUD) {
return { isLimitReached: false, limit: -1 };
}

// Admin/founder teams have no limits
if (await LimitService.isAdminOrFounderTeam(teamId)) {
return { isLimitReached: false, limit: -1 };
}

// Bounce / complaint rate enforcement (7-day rolling window)
const recentStats = await LimitService.getRecentBounceStats(teamId);
if (recentStats.delivered >= BOUNCE_RATE_MIN_VOLUME) {
Expand Down
Loading