mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 13:31:13 -05:00
Add ban reason to profiles
This commit is contained in:
@@ -4,11 +4,11 @@ import { edgeLogger } from "./logger.ts";
|
||||
export async function checkUserBanned(
|
||||
userId: string,
|
||||
supabase: SupabaseClient
|
||||
): Promise<{ banned: boolean; error?: string }> {
|
||||
): Promise<{ banned: boolean; ban_reason?: string; error?: string }> {
|
||||
try {
|
||||
const { data: profile, error } = await supabase
|
||||
.from('profiles')
|
||||
.select('banned')
|
||||
.select('banned, ban_reason')
|
||||
.eq('user_id', userId)
|
||||
.single();
|
||||
|
||||
@@ -21,18 +21,26 @@ export async function checkUserBanned(
|
||||
return { banned: false, error: 'Profile not found' };
|
||||
}
|
||||
|
||||
return { banned: profile.banned };
|
||||
return {
|
||||
banned: profile.banned,
|
||||
ban_reason: profile.ban_reason || undefined
|
||||
};
|
||||
} catch (error) {
|
||||
edgeLogger.error('Ban check exception', { userId, error });
|
||||
return { banned: false, error: 'Internal error checking account status' };
|
||||
}
|
||||
}
|
||||
|
||||
export function createBannedResponse(requestId: string, corsHeaders: Record<string, string>) {
|
||||
export function createBannedResponse(requestId: string, corsHeaders: Record<string, string>, ban_reason?: string) {
|
||||
const message = ban_reason
|
||||
? `Your account has been suspended. Reason: ${ban_reason}`
|
||||
: 'Your account has been suspended. Contact support for assistance.';
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: 'Account suspended',
|
||||
message: 'Your account has been suspended. Contact support for assistance.',
|
||||
message,
|
||||
ban_reason,
|
||||
requestId
|
||||
}),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user