AEB-71: Added 3D navigation in monitoring zones

This commit is contained in:
iv_vuytsik
2025-11-11 10:07:38 +03:00
parent 549a05509b
commit 88653cb07c
27 changed files with 503 additions and 184 deletions

View File

@@ -23,11 +23,32 @@ export async function GET(req: NextRequest) {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ refresh: refreshToken }),
})
if (refreshRes.ok) {
const refreshed = await refreshRes.json()
accessToken = refreshed.access
} else {
const errorText = await refreshRes.text()
let errorData: { error?: string; detail?: string; code?: string } = {}
try {
errorData = JSON.parse(errorText)
} catch {
errorData = { error: errorText }
}
const errorMessage = (errorData.error as string) || (errorData.detail as string) || ''
if (typeof errorMessage === 'string' &&
(errorMessage.includes('Token is expired') ||
errorMessage.includes('expired') ||
errorData.code === 'token_not_valid')) {
console.warn('Refresh token expired, user needs to re-authenticate')
} else {
console.error('Token refresh failed:', errorData.error || errorData.detail || 'Unknown error')
}
}
} catch {}
} catch (error) {
console.error('Error during token refresh:', error)
}
}
if (!accessToken) {
@@ -52,7 +73,21 @@ export async function GET(req: NextRequest) {
let payload: any
try { payload = JSON.parse(payloadText) } catch { payload = payloadText }
if (!objectsRes.ok) {
if (!objectsRes.ok) {
if (payload && typeof payload === 'object') {
if (payload.code === 'token_not_valid' ||
(payload.detail && typeof payload.detail === 'string' && (payload.detail.includes('Token is expired') || payload.detail.includes('Given token not valid'))) ||
(payload.messages && Array.isArray(payload.messages) && payload.messages.some((msg: any) =>
msg.message && typeof msg.message === 'string' && msg.message.includes('Token is expired')
))) {
console.warn('Access token expired, user needs to re-authenticate')
return NextResponse.json({
success: false,
error: 'Authentication required - please log in again'
}, { status: 401 })
}
}
const err = typeof payload === 'string' ? payload : JSON.stringify(payload)
return NextResponse.json({ success: false, error: `Backend objects error: ${err}` }, { status: objectsRes.status })
}