Add ban reason to profiles

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 02:51:16 +00:00
parent e0d1a66fb2
commit e5de404e59
8 changed files with 146 additions and 10 deletions

View File

@@ -105,6 +105,36 @@ Deno.serve(async (req) => {
console.log('[OAuth Profile] Processing profile for user:', user.id);
// CRITICAL: Check ban status immediately
const { data: banProfile } = await supabase
.from('profiles')
.select('banned, ban_reason')
.eq('user_id', user.id)
.single();
if (banProfile?.banned) {
const duration = endRequest(tracking);
const message = banProfile.ban_reason
? `Your account has been suspended. Reason: ${banProfile.ban_reason}`
: 'Your account has been suspended. Contact support for assistance.';
console.log('[OAuth Profile] User is banned, rejecting authentication', {
requestId: tracking.requestId,
duration,
hasBanReason: !!banProfile.ban_reason
});
return new Response(JSON.stringify({
error: 'Account suspended',
message,
ban_reason: banProfile.ban_reason,
requestId: tracking.requestId
}), {
status: 403,
headers: { ...corsHeaders, 'Content-Type': 'application/json', 'X-Request-ID': tracking.requestId },
});
}
const provider = user.app_metadata?.provider;
// For Discord, data is in identities[0].identity_data, not user_metadata