PageSourceSearch

https://alwaysintune.netlify.app/assets/Login-6M1cvswZ.js

js alwaysintune.netlify.app collected 2026-10-03 10:26:49 UTC 4,189 bytes, 1 lines download raw bytes

1import{a as n,j as s}from"./query-vendor-BB0JUlq_.js";import{g as N}from"./unsplash-gQ5iVEsL.js";import{a as C,s as k}from"./index-CVuSjWCq.js";import{d as L}from"./react-vendor-BIjsaQ6L.js";import"./ui-vendor-CwH6wFZJ.js";function P(){const[a,h]=n.useState(""),[u,x]=n.useState(""),[g,d]=n.useState(""),[w,f]=n.useState(!1),[p,y]=n.useState(null),c=L(),{loading:b}=C();n.useEffect(()=>{(async()=>{const t=["nature","guitar","musical instruments","acoustic guitar","piano"];let e=null;for(let o of t)if(e=await N(o),e)break;y(e)})()},[]);const j=async()=>{try{const t=await fetch("/api/auth/resend-verification",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a})});if(t.ok)alert("Verification email sent! Please check your email."),f(!1);else{const e=await t.json();alert(e.error||"Failed to resend verification email")}}catch{alert("Network error. Please try again.")}},S=async t=>{if(t.preventDefault(),d(""),!a||!u){d("Please enter both username/email and password");return}try{console.log("🔐 Login attempt with identifier:",a),console.log("📝 Sending request body:",{identifier:a.substring(0,5)+"...",password:"***"});const e=await fetch("/api/auth/login",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({identifier:a,password:u})});console.log("📡 Login response status:",e.status);try{const r=e.headers.get("X-CSRF-Token"),i=e.headers.get("X-Session-ID");r&&(window.localStorage.setItem("inTuneCSRF",r),console.log("✅ Captured CSRF token from login response")),i&&(window.localStorage.setItem("inTuneSessionID",i),console.log("✅ Captured Session ID from login response"))}catch(r){console.warn("⚠️ Failed to store session data:",r)}if(!e.ok){let r="Login failed",i=!1;const v=e.clone();try{const l=await e.json();console.log("📦 Error response:",l),r=l.error||l.details||"Login failed",i=r.includes("Email not verified")}catch(l){console.error("Failed to parse error response:",l);try{const m=await v.text();console.log("Response body (text):",m),r=`Login failed (${e.status}): ${m||"No response body"}`}catch(m){console.error("Failed to read cloned response:",m),r=`Login failed (${e.status})`}}d(r),f(i);return}const o=await e.json();console.log("✅ Login successful:",{id:o.id,role:o.role}),k(o),o.role==="admin"?c("/admin"):o.role==="teacher"?c("/teacher"):c("/dashboard")}catch(e){console.error("🔥 Login exception:",e),d(e?.message||"Login failed - check browser console for details")}};return b?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):s.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundImage:p?`linear-gradient(rgba(2,6,23,0.5), rgba(2,6,23,0.5)), url(${p})`:void 0,backgroundSize:"cover"},children:s.jsxs("div",{className:"bg-card/95 rounded-lg p-8 shadow-lg w-full max-w-md",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Login"}),s.jsx("p",{className:"text-sm text-foreground/70 mt-2",children:"Sign in with username or email and password."}),s.jsxs("form",{onSubmit:S,className:"mt-4",children:[s.jsx("input",{name:"identifier",value:a,onChange:t=>h(t.target.value),className:"w-full h-10 rounded-md border px-3 mb-2",placeholder:"Username or email",autoComplete:"username",required:!0}),s.jsx("input",{name:"password",value:u,onChange:t=>x(t.target.value),className:"w-full h-10 rounded-md border px-3",placeholder:"Password",type:"password",autoComplete:"current-password",required:!0}),s.jsx("div",{className:"mt-2 text-right",children:s.jsx("button",{type:"button",onClick:()=>c("/forgot-password"),className:"text-sm text-primary hover:underline",children:"Forgot password?"})}),g&&s.jsx("div",{className:"text-sm text-red-600 mt-2",children:g}),w&&s.jsx("div",{className:"mt-2",children:s.jsx("button",{type:"button",onClick:j,className:"text-sm text-primary hover:underline",children:"Resend verification email"})}),s.jsx("div",{className:"mt-4 flex justify-end",children:s.jsx("button",{type:"submit",className:"h-10 px-4 rounded-md bg-primary text-primary-foreground",children:"Sign in"})})]})]})})}export{P 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.