Кнопка «Проверить Supabase» на странице входа
This commit is contained in:
parent
8f04d65862
commit
60b95dcc2c
11
index.html
11
index.html
@ -77,6 +77,17 @@ document.getElementById('rbb').onclick=function(){
|
|||||||
fetch("https://znexbjafkvyjffffbhlf.supabase.co/rest/v1/users",{method:"POST",headers:{"apikey":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE","Content-Type":"application/json","Prefer":"resolution=merge-duplicates"},body:JSON.stringify({login:l,pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct})}).then(function(r){if(!r.ok){console.error("Supabase reg error:",r.status);alert("⚠️ Регистрация локально OK, но не сохранена в облако. С другого устройства вход будет недоступен.")}}).catch(function(e){console.error(e);alert("⚠️ Регистрация локально OK, но нет связи с облаком.")});
|
fetch("https://znexbjafkvyjffffbhlf.supabase.co/rest/v1/users",{method:"POST",headers:{"apikey":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE","Content-Type":"application/json","Prefer":"resolution=merge-duplicates"},body:JSON.stringify({login:l,pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct})}).then(function(r){if(!r.ok){console.error("Supabase reg error:",r.status);alert("⚠️ Регистрация локально OK, но не сохранена в облако. С другого устройства вход будет недоступен.")}}).catch(function(e){console.error(e);alert("⚠️ Регистрация локально OK, но нет связи с облаком.")});
|
||||||
ok.style.display='block';document.getElementById('lu').value=l;setTimeout(function(){ok.style.display='none';document.getElementById('tL').onclick()},2000)
|
ok.style.display='block';document.getElementById('lu').value=l;setTimeout(function(){ok.style.display='none';document.getElementById('tL').onclick()},2000)
|
||||||
};
|
};
|
||||||
|
function testSupabase(){
|
||||||
|
var SBU="https://znexbjafkvyjffffbhlf.supabase.co",SBK="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGxmIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc4MDY0NDE4MiwiZXhwIjoyMDk2MjIwMTgyfQ.5pOYTkL5eCmpSHBY3EwKof6NVKt7tL4Fn8xUAKM8itE";
|
||||||
|
// Тест: получить список пользователей
|
||||||
|
fetch(SBU+"/rest/v1/users?select=login",{headers:{"apikey":SBK,"Authorization":"Bearer "+SBK}}).then(function(r){return r.json()}).then(function(d){
|
||||||
|
if(Array.isArray(d)){
|
||||||
|
alert("✅ Supabase работает!\nПользователей в базе: "+d.length+"\nЛогины: "+d.map(function(x){return x.login}).join(", "));
|
||||||
|
}else{
|
||||||
|
alert("❌ Ошибка: "+JSON.stringify(d));
|
||||||
|
}
|
||||||
|
}).catch(function(e){alert("❌ Нет соединения с Supabase: "+e.message)});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user