- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler - veza-common: logging, metrics, traits, validation, random - veza-stream-server: audio pipeline, codecs, cache, monitoring, routes - apps/web/dist_verification: refresh build assets (content-hashed filenames) Co-authored-by: Cursor <cursoragent@cursor.com>
1 line
7.3 KiB
JavaScript
1 line
7.3 KiB
JavaScript
import{j as e,a as u}from"./vendor-react-C9dYU-TK.js";import{a as E,N as k,L}from"./vendor-router-Dr0ZB7zf.js";import{c as A,j as C,k as M,l as B,m as D}from"./index-BMBS6scK.js";import{A as y}from"./AuthInput-b0K9khMl.js";import{A as F,a as z}from"./AuthLayout-JL7y5GL_.js";import{F as I,e as q}from"./vendor-icons-BSV6HBy1.js";import{u as G,a as H}from"./vendor-tanstack-C4XaEYj2.js";import{C as P}from"./checkbox-BKePitYZ.js";import"./vendor-CjLUfV8Y.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-http-CctT3C58.js";import"./vendor-utils-D0JLFg89.js";import"./vendor-motion-CbAtAbUE.js";import"./vendor-i18n-PN7w4axr.js";const R={google:{label:"Google",ariaLabel:"Se connecter avec Google",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24","aria-hidden":"true",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]})},github:{label:"GitHub",ariaLabel:"Se connecter avec GitHub",icon:e.jsx(I,{className:"h-4 w-4","aria-hidden":"true"})},discord:{label:"Discord",ariaLabel:"Se connecter avec Discord",icon:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}};function h({provider:s,onClick:a,className:i}){const n=R[s];return e.jsxs("button",{type:"button",onClick:a,"aria-label":n.ariaLabel,className:A("w-full flex items-center justify-center gap-3 px-4 py-2.5 rounded-lg","bg-muted/50 border border-border text-foreground","hover:bg-muted hover:border-border/80 transition-all duration-[var(--duration-fast)]","focus:outline-none focus:ring-2 focus:ring-primary/20 focus:ring-offset-2 focus:ring-offset-background","text-sm font-medium",i),children:[n.icon,e.jsx("span",{children:n.label})]})}const O=()=>{const s=C(i=>i.login),a=G();return H({mutationFn:async i=>{const l=(await s(i)).user;return a.setQueryData(["user","me"],l),M().then(d=>{a.setQueryData(["user","me"],d)}).catch(()=>{}),{user:l,isAuthenticated:!0}}})};function Q(s){if(s==null)return"";if(typeof s=="object"&&s!==null&&"message"in s&&"code"in s)return D(s);if(s instanceof Error){const a=s.message?.toLowerCase()??"";return a.includes("invalid credentials")||a.includes("401")?"Incorrect email or password":a.includes("email not verified")?"Your email is not verified. Check your inbox.":a.includes("network")?"Connection error. Check your internet.":s.message||"An error occurred. Please try again."}return String(s)}function se(){const s=E(),{isAuthenticated:a,isLoading:i}=C(),{mutate:n,isPending:l,error:d}=O(),[o,p]=u.useState({email:"",password:""}),[c,m]=u.useState({}),[x,b]=u.useState(!1);if(u.useEffect(()=>{const r=localStorage.getItem("rememberedEmail");r&&(p(t=>({...t,email:r})),b(!0))},[]),a&&!i&&!l){const r=localStorage.getItem("auth-storage");if(r)try{const t=JSON.parse(r);if(t.state?.user&&t.state?.isAuthenticated)return e.jsx(k,{to:"/dashboard",replace:!0})}catch{}}const g=(r,t)=>{switch(r){case"email":return t?/\S+@\S+\.\S+/.test(t)?void 0:"Format email invalide":"Email requis";case"password":return t?t.length<6?"Le mot de passe doit contenir au moins 6 caractères":void 0:"Mot de passe requis";default:return}},S=()=>{const r={},t=g("email",o.email),w=g("password",o.password);return t&&(r.email=t),w&&(r.password=w),m(r),Object.keys(r).length===0},v=r=>{const t=g(r,o[r]);m({...c,[r]:t})},j=(r,t)=>{p({...o,[r]:t}),c[r]&&m({...c,[r]:void 0})},N=async r=>{r.preventDefault(),S()&&(x?localStorage.setItem("rememberedEmail",o.email):localStorage.removeItem("rememberedEmail"),n(o,{onSuccess:()=>{s("/dashboard",{replace:!0})},onError:t=>{B.error("Login error",{error:t instanceof Error?t.message:String(t),stack:t instanceof Error?t.stack:void 0})}}))},f=r=>{window.location.href=`/api/v1/auth/oauth/${r}`};return e.jsx(F,{title:"Welcome Back",subtitle:"Sign in to your account",footerLinks:[{label:"Don't have an account? Sign up",to:"/register"}],children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(h,{provider:"google",onClick:()=>f("google")}),e.jsx(h,{provider:"github",onClick:()=>f("github")}),e.jsx(h,{provider:"discord",onClick:()=>f("discord")})]}),e.jsxs("div",{className:"relative my-6",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-border"})}),e.jsx("div",{className:"relative flex justify-center text-xs",children:e.jsx("span",{className:"bg-card px-3 text-muted-foreground",children:"or continue with"})})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[d&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/30 text-destructive px-4 py-3 rounded-lg text-sm flex items-center gap-2 animate-in fade-in slide-in-from-top-1",role:"alert",children:[e.jsx(q,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("p",{children:Q(d)})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{type:"email",label:"Email",value:o.email,autoComplete:"email",onChange:r=>j("email",r.target.value),onBlur:()=>v("email"),error:c.email,required:!0}),e.jsx(y,{type:"password",label:"Password",value:o.password,autoComplete:"current-password",onChange:r=>j("password",r.target.value),onBlur:()=>v("password"),error:c.password,required:!0,showPasswordToggle:!0})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm min-w-0",children:[e.jsx(P,{id:"remember_me",checked:x,onCheckedChange:r=>b(r),label:"Remember me"}),e.jsx(L,{to:"/forgot-password",className:"text-sm text-muted-foreground hover:text-foreground hover:underline underline-offset-4 transition-colors duration-[var(--duration-fast)] flex-shrink-0",children:"Forgot password?"})]}),e.jsx(z,{type:"submit",loading:l,className:"w-full bg-primary text-primary-foreground hover:opacity-90 shadow-sm",children:"Sign In"})]})]})})}export{se as LoginPage,se as default};
|