mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-14 15:16:09 -05:00
Fix /suspended 500 when banned user row was deleted via migrate
This commit is contained in:
@@ -39,6 +39,8 @@ export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
errorToast(`Migration failed. Reason: ${errorMessage}`);
|
||||
}
|
||||
|
||||
await refreshBannedCache();
|
||||
|
||||
message = "Account migrated";
|
||||
break;
|
||||
} catch (err) {
|
||||
|
||||
@@ -6,14 +6,19 @@ import {
|
||||
} from "~/features/auth/core/authenticator.server";
|
||||
import { authSessionStorage } from "~/features/auth/core/session.server";
|
||||
import type { Nullish } from "~/utils/types";
|
||||
import { userIsBanned } from "../core/banned.server";
|
||||
import { refreshBannedCache, userIsBanned } from "../core/banned.server";
|
||||
|
||||
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
const userId = await getUserIdEvenIfBanned(request);
|
||||
|
||||
if (!userId || !userIsBanned(userId)) return redirect("/");
|
||||
|
||||
const bannedStatus = (await AdminRepository.allBannedUsers()).get(userId)!;
|
||||
const bannedStatus = (await AdminRepository.allBannedUsers()).get(userId);
|
||||
|
||||
if (!bannedStatus) {
|
||||
await refreshBannedCache();
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
return {
|
||||
banned: bannedStatus.banned,
|
||||
|
||||
Reference in New Issue
Block a user