Spaces:
Sleeping
Sleeping
File size: 1,445 Bytes
4bea261 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import { txasupabase } from '../../../lib/txasupabase.js';
export const GET = async ({ url }) => {
try {
const token = url.searchParams.get('token');
if (!token) {
return new Response(JSON.stringify({ error: 'Thiếu mã nhận diện trình duyệt!' }), {
status: 400,
headers: { 'Content-Type': 'application/json' }
});
}
if (token === 'txabypass' || token === 'bypass') {
return new Response(JSON.stringify({
success: true,
id: 'bypass',
zalo_nickname: 'Bypass Admin',
status: 'approved'
}), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
const access = await txasupabase.getZaloAccessByToken(token);
if (!access) {
return new Response(JSON.stringify({ status: 'not_found' }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
return new Response(JSON.stringify({
success: true,
id: access.id,
zalo_nickname: access.zalo_nickname,
status: access.status
}), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
} catch (err) {
console.error('Error handling access status API:', err);
return new Response(JSON.stringify({ error: 'Có lỗi xảy ra trên hệ thống!' }), {
status: 500,
headers: { 'Content-Type': 'application/json' }
});
}
};
|