Spaces:
Sleeping
Sleeping
| 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' } | |
| }); | |
| } | |
| }; | |