mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 10:11:12 -05:00
Add ban reason to profiles
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user