PageSourceSearch

https://hintermoos.at/assets/Auth-CkRy952c.js

js hintermoos.at collected 2026-10-09 22:01:40 UTC 17,910 bytes, 1 lines download raw bytes

1import{l as ce,r as u,o as de,p as me,a as ue,q as xe,t as he,u as J,j as e,L as pe,s as E,M as N,B as C,m as M,v as ge}from"./index-MoAbC8_9.js";import{h as fe}from"./house-login-DLa1j6M3.js";import{M as be}from"./mountain-BHfTfCFy.js";import{C as z}from"./circle-check-big-_JLEBINb.js";import{U as je}from"./user-Cvsz7Lm_.js";import{L as _}from"./lock-BEcuk4Jx.js";import{E as G}from"./eye-off-D1RUMkPr.js";import{E as q}from"./eye-DKrvAixa.js";import{G as Ne}from"./globe-DTZBS0aY.js";import{A as ve}from"./arrow-left-CZKmX_Y-.js";import{o as K,s as f}from"./types-3c7sL9OC.js";const we=K({email:f().email("Please enter a valid email address"),password:f().min(6,"Password must be at least 6 characters")}),ye=K({fullName:f().min(2,"Name must be at least 2 characters"),email:f().email("Please enter a valid email address"),password:f().min(6,"Password must be at least 6 characters"),confirmPassword:f()}).refine(h=>h.password===h.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]}),ze=()=>{var V;const[h]=ce(),T=()=>h.get("forgot")==="1"?"forgot":h.get("tab")==="signup"?"signup":"login",[p,l]=u.useState(T),[n,x]=u.useState(!1),[g,H]=u.useState({email:"",password:""}),[c,L]=u.useState({fullName:"",email:"",password:"",confirmPassword:""}),[v,Q]=u.useState(""),[w,X]=u.useState(""),[o,m]=u.useState({}),[Y,Z]=u.useState(!1),[b,B]=u.useState(!1),{signIn:ee,signUp:se,user:R}=de(),{isAdmin:I,isReady:O}=me(),W=ue(),te=xe(),{toast:j}=he(),{t:s}=J(),S=(V=te.state)==null?void 0:V.from,$=h.get("redirect")||(S?`${S.pathname}${S.search||""}${S.hash||""}`:void 0);u.useEffect(()=>{(async()=>{const{data:a}=await E.rpc("is_magic_link_enabled");a===!0&&Z(!0)})()},[]),u.useEffect(()=>{R&&O&&W($||(I?"/admin":"/owners"),{replace:!0})},[R,O,I,W,$]);const ae=async(t,a,i)=>{const r=navigator.userAgent;let d="Neznámý",k="Neznámý",P="Desktop";r.includes("Firefox")?d="Firefox":r.includes("Edg")?d="Edge":r.includes("Chrome")?d="Chrome":r.includes("Safari")&&(d="Safari"),r.includes("Windows")?k="Windows":r.includes("Mac OS")?k="macOS":r.includes("Android")?(k="Android",P="Mobil"):(r.includes("iPhone")||r.includes("iPad"))&&(k="iOS",P=r.includes("iPad")?"Tablet":"Mobil"),r.includes("Mobile")&&(P="Mobil");const D=ge(r);try{await E.from("login_history").insert({user_id:null,user_agent:r,device_type:P,browser:d,os:k,login_method:a,status:"failed",failure_reason:i,attempted_email:t,is_suspected_bot:D.isSuspected,bot_detection_reason:D.reason,bot_score:D.score})}catch{}},re=async t=>{t.preventDefault(),m({});const a=we.safeParse(g);if(!a.success){const r={};a.error.errors.forEach(d=>{d.path[0]&&(r[d.path[0].toString()]=d.message)}),m(r);return}x(!0);const{error:i}=await ee(g.email,g.password);x(!1),i&&(ae(g.email,"password",i.message),j({variant:"destructive",title:s("auth.login"),description:i.message==="Invalid login credentials"?s("auth.invalidCredentials"):i.message}))},ie=async t=>{t.preventDefault(),m({});const a=ye.safeParse(c);if(!a.success){const r={};a.error.errors.forEach(d=>{d.path[0]&&(r[d.path[0].toString()]=d.message)}),m(r);return}x(!0);const{error:i}=await se(c.email,c.password,c.fullName);if(i){x(!1),j({variant:"destructive",title:s("auth.register"),description:i.message});return}try{await E.functions.invoke("send-auth-email",{body:{email:c.email,type:"signup_confirmation",redirectTo:window.location.origin,fullName:c.fullName}})}catch(r){console.error("Custom signup email failed, default will be used:",r)}x(!1),l("signup-sent")},le=async t=>{if(t.preventDefault(),m({}),!v||!f().email().safeParse(v).success){m({forgotEmail:s("auth.invalidEmail")});return}x(!0);try{const{data:a,error:i}=await E.functions.invoke("send-auth-email",{body:{email:v,type:"password_reset",redirectTo:window.location.origin}});i||a!=null&&a.error?j({variant:"destructive",title:s("auth.forgotPassword"),description:(i==null?void 0:i.message)||(a==null?void 0:a.error)||"Error sending reset email"}):l("forgot-sent")}catch{j({variant:"destructive",title:s("auth.forgotPassword"),description:"An unexpected error occurred."})}x(!1)},ne=async t=>{if(t.preventDefault(),m({}
1),!w||!f().email().safeParse(w).success){m({magicLinkEmail:"Please enter a valid email address"});return}x(!0);try{const{data:a,error:i}=await E.functions.invoke("send-magic-link",{body:{email:w,redirectTo:window.location.origin}});i||a!=null&&a.error?j({variant:"destructive",title:s("auth.magicLinkError"),description:(i==null?void 0:i.message)||(a==null?void 0:a.error)}):l("magiclink-sent")}catch{j({variant:"destructive",title:s("auth.magicLinkError"),description:"An unexpected error occurred."})}x(!1)},y="w-full h-12 pl-10 pr-4 rounded-lg bg-white/70 text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/30 backdrop-blur-sm border border-border",F="w-full h-12 pl-10 pr-12 rounded-lg bg-white/70 text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/30 backdrop-blur-sm border border-border",A=()=>e.jsxs("div",{className:"text-left rounded-lg border border-border bg-muted/40 p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("auth.emailHintTitle")}),e.jsxs("ul",{className:"space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:[e.jsx("li",{children:s("auth.emailHintSpam")}),e.jsx("li",{children:s("auth.emailHintSender")}),e.jsx("li",{children:s("auth.emailHintWait")})]})]}),U=()=>e.jsxs("button",{type:"button",onClick:()=>{l("login"),m({})},className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground mb-4",children:[e.jsx(ve,{className:"h-4 w-4"}),s("auth.backToLogin")]}),oe=()=>p==="magiclink-sent"?e.jsxs("div",{className:"text-center space-y-6",children:[e.jsx(z,{className:"h-16 w-16 mx-auto text-primary"}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:s("auth.checkEmail")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("auth.magicLinkSent")}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:w}),e.jsx(A,{}),e.jsx("button",{onClick:()=>l("login"),className:"text-sm underline text-muted-foreground hover:text-foreground",children:s("auth.usePassword")})]}):p==="signup-sent"?e.jsxs("div",{className:"text-center space-y-6",children:[e.jsx(z,{className:"h-16 w-16 mx-auto text-primary"}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:s("auth.checkEmail")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("auth.signupEmailSentApproval")}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:c.email}),e.jsx(A,{}),e.jsx("button",{onClick:()=>l("login"),className:"text-sm underline text-muted-foreground hover:text-foreground",children:s("auth.backToLogin")})]}):p==="forgot-sent"?e.jsxs("div",{className:"text-center space-y-6",children:[e.jsx(z,{className:"h-16 w-16 mx-auto text-primary"}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:s("auth.checkEmail")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("auth.resetEmailSent")}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:v}),e.jsx(A,{}),e.jsx("button",{onClick:()=>l("login"),className:"text-sm underline text-muted-foreground hover:text-foreground",children:s("auth.backToLogin")})]}):p==="forgot"?e.jsxs(e.Fragment,{children:[e.jsx(U,{}),e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:s("auth.forgotPasswordTitle")}),e.jsx("p",{className:"text-sm mb-8 text-muted-foreground",children:s("auth.forgotPasswordDescription")}),e.jsxs("form",{onSubmit:le,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.email")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:v,onChange:t=>Q(t.target.value),disabled:n,className:y})]}),o.forgotEmail&&e.jsx("p",{className:"text-sm text-destructive",children:o.forgotEmail})]}),e.jsx(C,{type:"submit",className:"w-full h-12 rounded-lg text-base font-semibold bg-primary hover:bg-primary/90 text-primary-foreground shadow-md",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"mr-2 h-4 w-4 animate-spin"}
1),s("auth.sendResetLink"),"..."]}):s("auth.sendResetLink")})]})]}):p==="signup"?e.jsxs(e.Fragment,{children:[e.jsx(U,{}),e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:s("auth.registerTitle")}),e.jsx("p",{className:"text-sm mb-8 text-muted-foreground",children:s("auth.registerSubtitle")}),e.jsxs("form",{onSubmit:ie,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.fullName")}),e.jsxs("div",{className:"relative",children:[e.jsx(je,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:"text",placeholder:s("auth.fullNamePlaceholder"),value:c.fullName,onChange:t=>L({...c,fullName:t.target.value}),disabled:n,className:y})]}),o.fullName&&e.jsx("p",{className:"text-sm text-destructive",children:o.fullName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.email")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:c.email,onChange:t=>L({...c,email:t.target.value}),disabled:n,className:y})]}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.password")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:b?"text":"password",placeholder:"••••••••",value:c.password,onChange:t=>L({...c,password:t.target.value}),disabled:n,className:F}),e.jsx("button",{type:"button",onClick:()=>B(!b),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:b?e.jsx(G,{className:"h-4 w-4"}):e.jsx(q,{className:"h-4 w-4"})})]}),o.password&&e.jsx("p",{className:"text-sm text-destructive",children:o.password})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.confirmPassword")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:"password",placeholder:"••••••••",value:c.confirmPassword,onChange:t=>L({...c,confirmPassword:t.target.value}),disabled:n,className:F})]}),o.confirmPassword&&e.jsx("p",{className:"text-sm text-destructive",children:o.confirmPassword})]}),e.jsx(C,{type:"submit",className:"w-full h-12 rounded-lg text-base font-semibold bg-primary hover:bg-primary/90 text-primary-foreground shadow-md",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"mr-2 h-4 w-4 animate-spin"}),s("auth.register"),"..."]}):s("auth.register")})]})]}):p==="magiclink"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:s("auth.useMagicLink")}),e.jsx("p",{className:"text-sm mb-8 text-muted-foreground",children:s("auth.magicLinkDescription")}),e.jsxs("form",{onSubmit:ne,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.email")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:w,onChange:t=>X(t.target.value),disabled:n,className:y})]}),o.magicLinkEmail&&e.jsx("p",{className:"text-sm text-destructive",children:o.magicLinkEmail})]}),e.jsx(C,{type:"submit",className:"w-full h-12 rounded-lg text-base font-semibold bg-primary hover:bg-primary/90 text-primary-foreground",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"mr-2 h-4 w-4 animate-spin"}),s("auth.sendMagicLink"),"..."]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),s("auth.sendMagicLink")]})}),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-border"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"px-2 text-muted-foreground bg-white/70 backdrop-blur-sm rounded",children:s("auth.or")}
1)})]}),e.jsxs("button",{type:"button",onClick:()=>l("login"),className:"w-full h-12 rounded-lg text-base font-semibold flex items-center justify-center gap-2 transition-colors bg-primary/10 hover:bg-primary/20 text-primary border border-primary/20 backdrop-blur-sm",children:[e.jsx(_,{className:"h-4 w-4"}),s("auth.usePassword")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:s("auth.login")}),e.jsx("p",{className:"text-sm mb-8 text-muted-foreground",children:s("auth.loginSubtitle")}),e.jsxs("form",{onSubmit:re,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.email")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:g.email,onChange:t=>H({...g,email:t.target.value}),disabled:n,className:y})]}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-primary",children:s("auth.password")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-accent z-10 pointer-events-none"}),e.jsx("input",{type:b?"text":"password",placeholder:"••••••••",value:g.password,onChange:t=>H({...g,password:t.target.value}),disabled:n,className:F}),e.jsx("button",{type:"button",onClick:()=>B(!b),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:b?e.jsx(G,{className:"h-4 w-4"}):e.jsx(q,{className:"h-4 w-4"})})]}),o.password&&e.jsx("p",{className:"text-sm text-destructive",children:o.password})]}),e.jsx(C,{type:"submit",className:"w-full h-12 rounded-lg text-base font-semibold bg-primary hover:bg-primary/90 text-primary-foreground shadow-md",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"mr-2 h-4 w-4 animate-spin"}),s("auth.login"),"..."]}):s("auth.login")}),Y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative my-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-border"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"px-2 text-muted-foreground bg-white/70 backdrop-blur-sm rounded",children:s("auth.or")})})]}),e.jsxs("button",{type:"button",onClick:()=>l("magiclink"),className:"w-full h-12 rounded-lg text-base font-semibold flex items-center justify-center gap-2 transition-colors bg-primary/10 hover:bg-primary/20 text-primary border border-primary/20 backdrop-blur-sm",children:[e.jsx(N,{className:"h-4 w-4"}),s("auth.loginWithoutPassword")]})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-8",children:[e.jsx("button",{onClick:()=>{l("forgot"),m({})},className:"text-sm hover:underline text-muted-foreground hover:text-foreground",children:s("auth.forgotPassword")}),e.jsx("button",{onClick:()=>{l("signup"),m({})},className:"text-sm hover:underline text-muted-foreground hover:text-foreground",children:s("auth.register")})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-8",children:[e.jsx(Ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ke,{})]})]});return e.jsxs("div",{className:"min-h-screen relative flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:`url(${fe})`}}),e.jsx("div",{className:"absolute inset-0 bg-white/80"}),e.jsxs("div",{className:"relative z-10 w-full max-w-lg px-8 py-12",children:[e.jsxs(pe,{to:"/",className:"flex items-center justify-center gap-3 mb-6 group",title:s("auth.backToHome"),children:[e.jsx(be,{className:"h-8 w-8 text-primary group-hover:scale-110 transition-transform"}),e.jsxs("div",{className:"flex flex-col leading-tight",children:[e.jsx("span",{className:"font-serif text-[10px] tracking-[0.2em] uppercase text-muted-foreground",children:"Appartementhaus"}),e.jsx("span",{className:"font-serif text-xl text-foreground group-hover:text-primary transition-colors",children:"Hintermoos"})]})]}),e.jsx("div",{className:"bg-white/95 backdrop-blur-sm rounded-xl shadow-lg border border-border/50 px-8 py-10",children:oe()})]})]})},ke=()=>{const{language:h,setLanguage:T}=J(),p=[{code:"cs",label:"ČeÅ¡tina"},{code:"de",label:"Deutsch"},{code:"en",label:"English"}];return e.jsx("select",{value:h,onChange:l=>T(l.target.value),className:"bg-transparent text-sm cursor-pointer focus:outline-none text-muted-foreground",children:p.map(l=>e.jsx("option",{value:l.code,className:"bg-background text-foreground",children:l.label},l.code))})};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.