PageSourceSearch

https://janex-net.pl/assets/Login-a70B3oyL.js

js janex-net.pl collected 2026-10-08 17:30:52 UTC 9,775 bytes, 1 lines download raw bytes

1import{j as e,m as oe}from"./motion-ByrmHL-7.js";import{u as ie,s as o,S as ce,W as le,a as de,M as Z,L as x,I as w,B as C,b as J,c as me}from"./index-CBCj37G3.js";import{r as a,d as ue,h as he}from"./react-vendor-Dye3IoJs.js";import{A as xe}from"./AdminSms2FA-nZL6gXJZ.js";import{L as we}from"./log-in-DDAl0Ph7.js";import{K as pe,E as K}from"./key-round-CuHwgZrH.js";import{E as q}from"./eye-vZx5HBar.js";import{A as fe}from"./arrow-left-BCySQ_Pc.js";import"./ui-vendor-BR6OGFid.js";import"./send-BI062Imi.js";const je=5,ge=6e4,ze=()=>{const[c,P]=a.useState(""),[y,V]=a.useState(""),[m,A]=a.useState(""),[b,F]=a.useState(""),[i,z]=a.useState(!1),[l,s]=a.useState(""),[p,u]=a.useState("login"),[B,L]=a.useState(!1),[_,R]=a.useState(!1),[E,O]=a.useState(!1),[v,D]=a.useState(""),{login:X,isLoading:U}=ie(),f=ue(),[Y]=he(),$=Y.get("admin")==="1",N=a.useRef(0),S=a.useRef(0),[G,j]=a.useState(!1),[Q,W]=a.useState(""),[M,T]=a.useState("/admin");a.useEffect(()=>{const{data:{subscription:t}}=o.auth.onAuthStateChange(h=>{h==="PASSWORD_RECOVERY"&&(u("set-password"),s(""))}),n=window.location.hash;if(n.includes("token_hash=")&&n.includes("type=recovery")){const g=new URLSearchParams(n.substring(1)).get("token_hash");g&&o.auth.verifyOtp({token_hash:g,type:"recovery"}).then(({error:d})=>{d?(console.error("Token verification error:",d),s("Link do ustawienia hasła wygasł lub jest nieprawidłowy. Użyj opcji 'Przypomnij hasło'.")):(u("set-password"),s("")),window.history.replaceState(null,"",window.location.pathname+window.location.search)})}return()=>t.unsubscribe()},[]);const H=()=>S.current>Date.now(),k=()=>{N.current+=1,N.current>=je&&(S.current=Date.now()+ge,N.current=0)},ee=async t=>{var n;if(t.preventDefault(),s(""),!v){if(H()){const h=Math.ceil((S.current-Date.now())/1e3);s(`Zbyt wiele prób logowania. Spróbuj ponownie za ${h}s.`);return}if(!c||!y){s("Wypełnij wszystkie pola");return}try{if(await X(c,y)){const{data:g}=await o.auth.getUser(),d=(n=g.user)==null?void 0:n.id;let I=!1;if(d){const{data:ne}=await o.from("user_roles").select("role").eq("user_id",d).eq("role","admin").maybeSingle();I=!!ne}const{data:r}=await o.from("profiles").select("admin_2fa_enabled, customer_2fa_enabled, phone").eq("user_id",d).maybeSingle();if(I){if(r!=null&&r.admin_2fa_enabled&&(r!=null&&r.phone)){W(r.phone),T("/admin"),j(!0);return}f("/admin")}else{if(r!=null&&r.customer_2fa_enabled&&(r!=null&&r.phone)){W(r.phone),T("/panel"),j(!0);return}f("/panel")}}else k(),s("Nieprawidłowy email lub hasło")}catch{k(),s("Nieprawidłowy email lub hasło")}}},se=a.useCallback(()=>{j(!1),f(M)},[f,M]),te=a.useCallback(async()=>{j(!1),await o.auth.signOut(),s("Weryfikacja dwuskładnikowa anulowana")},[]),ae=async t=>{if(t.preventDefault(),s(""),!v){if(H()){s("Zbyt wiele prób. Spróbuj ponownie za chwilę.");return}if(!c){s("Podaj adres email");return}R(!0);try{await o.functions.invoke("reset-password",{body:{email:c,siteUrl:window.location.origin}})}catch(n){console.error("Recovery error:",n)}L(!0),R(!1),k()}},re=async t=>{if(t.preventDefault(),s(""),!m||!b){s("Wypełnij oba pola");return}if(m.length<6){s("Hasło musi mieć minimum 6 znaków");return}if(m!==b){s("Hasła nie są identyczne");return}O(!0);try{const{error:n}=await o.auth.updateUser({password:m});n?(s("Nie udało się ustawić hasła. Spróbuj ponownie."),console.error("Update password error:",n)):(me.success("Hasło zostało ustawione! Możesz się teraz zalogować."),await o.auth.signOut(),u("login"),A(""),F(""))}catch(n){console.error("Set password error:",n),s("Wystąpił błąd. Spróbuj ponownie.")}finally{O(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-background px-4",style:{background:"var(--hero-gradient)"},children:[e.jsx(ce,{title:"Logowanie — Janex-Net",description:"Logowanie do panelu klienta Janex-Net.",noindex:!0}),e.jsx(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-border/50 p-8",children:[e.jsx("div",{className:"absolute -left-[9999px]","aria-hidden":"true",children:e.jsx("input",{type:"text",name:"website",tabIndex:-1,autoComplete:"off",value:v,onCh
1ange:t=>D(t.target.value)})}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs("a",{href:"/",className:"inline-flex items-center gap-2 text-xl font-bold tracking-tight text-primary mb-2",children:[e.jsx(le,{className:"h-6 w-6 text-accent"}),e.jsx("span",{children:"Janex-Net"})]}),p==="login"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground mt-4 flex items-center justify-center gap-2",children:$?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-5 w-5 text-accent"}),"Panel Administratora"]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-5 w-5 text-accent"}),"Panel Klienta"]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Zaloguj się używając danych otrzymanych na email"})]}):p==="set-password"?e.jsxs(e.Fragment,{children:[e.jsxs("h1",{className:"text-lg font-semibold text-foreground mt-4 flex items-center justify-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-accent"}),"Ustaw nowe hasło"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Wprowadź nowe hasło do swojego konta"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("h1",{className:"text-lg font-semibold text-foreground mt-4 flex items-center justify-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5 text-accent"}),"Odzyskiwanie hasła"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Podaj adres email, na który wyślemy link do resetowania hasła"})]})]}),p==="login"?e.jsxs("form",{onSubmit:ee,className:"space-y-4",autoComplete:"on",children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:"email",children:"Adres email"}),e.jsx(w,{id:"email",name:"email",type:"email",autoComplete:"username",placeholder:"[email protected]",value:c,onChange:t=>P(t.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"password",children:"Hasło"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(w,{id:"password",name:"password",type:i?"text":"password",autoComplete:"current-password",placeholder:"••••••••",value:y,onChange:t=>V(t.target.value)}),e.jsx("button",{type:"button",onClick:()=>z(!i),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:i?e.jsx(K,{className:"h-4 w-4"}):e.jsx(q,{className:"h-4 w-4"})})]})]}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l}),e.jsx(C,{type:"submit",disabled:U,className:"w-full bg-accent text-accent-foreground hover:bg-accent/90",children:U?"Logowanie...":"Zaloguj się"}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("button",{type:"button",onClick:()=>{u("recovery"),s("")},className:"text-sm text-muted-foreground hover:text-accent transition-colors",children:"Nie pamiętam hasła"})})]}):p==="set-password"?e.jsxs("form",{onSubmit:re,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:"new-password",children:"Nowe hasło"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(w,{id:"new-password",type:i?"text":"password",autoComplete:"new-password",placeholder:"Min. 6 znaków",value:m,onChange:t=>A(t.target.value)}),e.jsx("button",{type:"button",onClick:()=>z(!i),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:i?e.jsx(K,{className:"h-4 w-4"}):e.jsx(q,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"confirm-password",children:"Powtórz hasło"}),e.jsx(w,{id:"confirm-password",type:i?"text":"password",autoComplete:"new-password",placeholder:"Powtórz hasło",value:b,onChange:t=>F(t.target.value),className:"mt-1"})]}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l}),e.jsx(C,{type:"submit",disabled:E,className:"w-full bg-accent text-accent-foreground hover:bg-accent/90",children:E?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-4 w-4 mr-2 animate-spin"}),"Zapisywanie..."]}):"Ustaw hasło"})]}):e.jsxs("form",{onSubmit:ae,className:"space-y-4",children:[B?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-accent/5 flex items-center justify-center",children:e.jsx(Z,{className:"h-6 w-6 text-accent"})}),e.jsx("p",{className:"text-sm text-foreground",children:"Jeśli konto z podanym adresem email istnieje, wysłaliśmy link do resetowania hasła."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sprawdź skrzynkę odbiorczą oraz folder spam."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:"recovery-email",children:"Adres email"}),e.jsx(w,{id:"recovery-email",type:"email",placeholder:"[email protected]",value:c,onChange:t=>P(t.target.value),className:"mt-1"})]}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l}),e.jsx(C,{type:"submit",disabled:_,className:"w-full bg-accent text-accent-foreground hover:bg-accent/90",children:_?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-4 w-4 mr-2 animate-spin"}),"Wysyłanie..."]}):"Wyślij link do resetowania"})]}),e.jsxs("button",{type:"button",onClick:()=>{u("login"),s(""),L(!1)},className:"w-full text-sm text-muted-foreground hover:text-accent transition-colors flex items-center justify-center gap-1",children:[e.jsx(fe,{className:"h-3 w-3"}),"Powrót do logowania"]})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("a",{href:"/",className:"text-sm text-muted-foreground hover:text-accent transition-colors",children:"← Powrót do strony głównej"})})]})}),e.jsx(xe,{open:G,phone:Q,onVerified:se,onCancel:te})]})};export{ze as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.