Регистрация отправляет в Supabase через fetch напрямую
This commit is contained in:
parent
faa69e8cbd
commit
801df72196
@ -64,7 +64,10 @@ document.getElementById('lp').onkeydown=function(e){if(e.key==='Enter')document.
|
||||
document.getElementById('rbb').onclick=function(){
|
||||
var l=document.getElementById('rl').value.trim().toLowerCase(),p=document.getElementById('rp').value.trim(),n=document.getElementById('rn').value.trim(),em=document.getElementById('re').value.trim(),r=document.getElementById('rr').value,fr=document.getElementById('rf').value,br=document.getElementById('rb').value.trim(),dp=document.getElementById('rd').value.trim(),rg=document.getElementById('rg').value.trim(),ob=document.getElementById('ro').value.trim(),ct=document.getElementById('rc').value.trim();
|
||||
var e=document.getElementById('rerr'),ok=document.getElementById('rok');ok.style.display='none';if(!l||l.length<2){e.textContent='Логин мин. 2 символа';e.style.display='block';return}if(!p||p.length<3){e.textContent='Пароль мин. 3 символа';e.style.display='block';return}if(!n){e.textContent='Укажите ФИО';e.style.display='block';return}if(!r){e.textContent='Выберите должность';e.style.display='block';return}if(!em||em.indexOf('@')<0){e.textContent='Укажите Email';e.style.display='block';return}if(!br){e.textContent='Укажите филиал';e.style.display='block';return}if(!rg){e.textContent='Укажите регион';e.style.display='block';return}if(!ct){e.textContent='Укажите город';e.style.display='block';return}if(!dp){e.textContent='Укажите подразделение';e.style.display='block';return}if(!fr){e.textContent='Укажите периодичность ПАБ';e.style.display='block';return}
|
||||
var users={};try{users=JSON.parse(localStorage.getItem('pab_users')||'{}')}catch(e){}if(users[l]){e.textContent='Логин занят';e.style.display='block';return}e.style.display='none';users[l]={pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct};localStorage.setItem('pab_users',JSON.stringify(users));ok.style.display='block';document.getElementById('lu').value=l;setTimeout(function(){ok.style.display='none';document.getElementById('tL').onclick()},2000)
|
||||
var users={};try{users=JSON.parse(localStorage.getItem('pab_users')||'{}')}catch(e){}if(users[l]){e.textContent='Логин занят';e.style.display='block';return}e.style.display='none';users[l]={pass:p,name:n,email:em,role:r,freq:fr,branch:br,dept:dp,region:rg,oblast:ob,city:ct};localStorage.setItem('pab_users',JSON.stringify(users));ok.style.display='block';
|
||||
// Отправка в Supabase
|
||||
try{var SBU="https://znexbjafkvyjffffbhlf.supabase.co",SBK="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InpuZXhiamFma3Z5amZmZmZiaGhsZiIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNzgwNjQ0MTgyLCJleHAiOjIwOTYyMjAxODJ9.fhKixmi5Tx6yB-rRkGqHzOdepbXq3BoETdh7s__aDRk";fetch(SBU+"/rest/v1/users",{method:"POST",headers:{"apikey":SBK,"Authorization":"Bearer "+SBK,"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){console.log("SB reg:",r.ok?"OK":r.status)})}catch(e){}
|
||||
document.getElementById('lu').value=l;setTimeout(function(){ok.style.display='none';document.getElementById('tL').onclick()},2000)
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user