PageSourceSearch

https://agence-tribu.fr/assets/Auth-DSJS3F0s.js

js agence-tribu.fr collected 2026-09-30 06:37:20 UTC 8,055 bytes, 6 lines download raw bytes

1import{j as r}from"./ui-vendor-BqP7nUKl.js";import{r as v,u as I}from"./react-vendor-DKmRkCg0.js";import{c as L,s as E,u as N,t as p,l as O,N as R}from"./index-B70RwDyr.js";import{I as j}from"./input-DXQ0J_JV.js";import{L as k}from"./label-hXh--SCA.js";import{C as U,a as D,b as M,c as $,d as F}from"./card-Dv0SWS47.js";import{o as B,s as S}from"./types-Brh0Yyyl.js";import"./supabase-Bd53hCCy.js";import"./query-CrneLqUN.js";import"./motion-wteJqCuK.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const H=L("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]),K="authorization_response",V="/~oauth/initiate",W=["https://oauth.lovable.app","https://lovable.dev"],z="lovable://oauth-callback",q="http://127.0.0.1/iframe-oauth/callback",G=500,X=12e4,Y=/LovableAppScheme\/([a-z0-9.+-]+)/i;function J(e){const s=Y.exec(e)?.[1];return s?`${s}://oauth-callback`:z}function Q(e){let s;const n=new Promise(a=>{s=a}),i=a=>{if(!e.some(d=>a.origin===d))return;const o=a.data;!o||typeof o!="object"||o.type===K&&s(o.response)},h=()=>{window.removeEventListener("message",i)};return window.addEventListener("message",i),{cleanup:h,messagePromise:n}}function Z(e){const s=window.screenX!==0||window.screenY!==0||!e,n=s?window.outerWidth*.5:window.screen.width*.5,i=s?window.outerHeight*.5:window.screen.height*.5;return{width:n,height:i,left:s?window.screenX+(window.outerWidth-n)/2:(window.screen.width-n)/2,top:s?window.screenY+(window.outerHeight-i)/2:(window.screen.height-i)/2}}function T(e,s){return e.state!==s?{error:new Error("State is invalid")}:e.error?e.error==="legacy_flow"?{error:new Error("This flow is not supported in Preview mode. Please open the app in a new tab to sign in.")}:{error:new Error(e.error_description??"Sign in failed")}:!e.access_token||!e.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:e.access_token,refresh_token:e.refresh_token},error:null}}function ee(){const e=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}function re(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function te(e={}){const s=e.oauthBrokerUrl??V,n=e.supportedOAuthOrigins??W;async function i(h,a={}){let o=!1;try{o=window.self!==window.top}catch{o=!0}const d=navigator.userAgent,m=/LovableApp\//.test(d),u=!m&&/lovable/i.test(d),t=re();let l=a.redirect_uri??window.location.origin;m&&o?l=J(d):u&&o&&(l=q);const g=new URLSearchParams({...a.extraParams,provider:h,redirect_uri:l,state:t});if(!o)return window.location.href=`${s}?${g.toString()}`,{error:null,redirected:!0};!m&&!u&&g.set("response_mode","web_message");const P=`${s}?${g.toString()}`,{messagePromise:A,cleanup:y}=Q(u?[...n,window.location.origin]:n);let w;if(ee())w=window.open(P,"_blank");else{const{width:c,height:x,left:f,top:_}=Z(o);w=window.open(P,"oauth",`width=${c},height=${x},left=${f},top=${_}`)}if(!w&&(m||u)){let c;const x=new Promise((f,_)=>{c=setTimeout(()=>{_(new Error("OAuth timed out waiting for response"))},X)});try{return T(await Promise.race([A,x]),t)}catch(f){return{error:f instanceof Error?f:new Error(String(f))}}finally{c&&clearTimeout(c),y()}}if(!w)return y(),{error:new Error("Popup was blocked")};let b;const C=new Promise((c,x)=>{b=setInterval(()=>{w.closed&&(clearInterval(b),x(new Error("Sign in was cancelled")))},G)});try{return T(await Promise.race([A,C]),t)}catch(c){return{error:c instanceof Error?c:new Error(String(c))}}finally{clearInterval(b),y(),w?.close()}}return{signInWithOAuth:i}}function se(e={}){return te(e)}const ne=se(),oe={auth:{signInWithOAuth:async(e,s)=>{const n=await ne.signInWithOAuth(e,{...s,extraParams:{...s?.extraParams}});if(n.redirected||n.error)return n;try{await E.auth.setSession(n.tokens)}catch(i){return{error:i instanceof Error?i:new Error(String(i))}}return n}}},ie=B({email:S().email({message:"Email invalide"}).max(255),password:S().min(6,{message:"Le mot de passe doit contenir au moins 6 caractères"}).max(100)}),ge=()=>{const[e,s]=v.useState(""),[n,i]=v.useState(""),[h,a]=v.useState(!1),{user:o,signIn:d}=N(),m=I();v.useEffect(()=>{if(!o)return;let t=!1;return(async()=>{const{data:l}
6=await E.from("user_roles").select("role").eq("user_id",o.id).eq("role","admin").maybeSingle();t||(l?m("/admin"):(await E.auth.signOut(),p({title:"Session client détectée",description:"Elle a été fermée. Connectez-vous avec votre compte administrateur."})))})(),()=>{t=!0}},[o,m]);const u=async()=>{const t=ie.safeParse({email:e,password:n});if(!t.success){p({title:"Erreur de validation",description:t.error.errors[0].message,variant:"destructive"});return}a(!0);const{error:l}=await d(e,n);if(a(!1),l){const g=l.message.includes("Invalid login credentials")?"Email ou mot de passe incorrect":l.message;p({title:"Erreur",description:g,variant:"destructive"})}};return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-hero p-4",children:r.jsxs(U,{className:"w-full max-w-md",children:[r.jsxs(D,{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:O,alt:"Tribu Productions",className:"h-12"})}),r.jsx(M,{className:"text-2xl",children:"Connexion administration"}),r.jsx($,{children:"Réservé à l'équipe Tribu Productions"})]}),r.jsxs(F,{className:"space-y-4",children:[r.jsxs("button",{type:"button",onClick:async()=>{(await oe.auth.signInWithOAuth("google",{redirect_uri:window.location.origin+"/auth"})).error&&p({title:"Erreur",description:"La connexion Google a échoué.",variant:"destructive"})},className:"w-full flex items-center justify-center gap-2 rounded-xl border border-border bg-background px-4 py-2.5 text-sm font-medium hover:bg-muted transition-colors",children:[r.jsx(H,{className:"h-4 w-4"}),"Continuer avec Google"]}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute inset-0 flex items-center",children:r.jsx("span",{className:"w-full border-t border-border"})}),r.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:r.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"ou"})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(k,{htmlFor:"login-email",children:"Email"}),r.jsx(j,{id:"login-email",type:"email",placeholder:"[email protected]",value:e,onChange:t=>s(t.target.value),onKeyDown:t=>t.key==="Enter"&&u()})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(k,{htmlFor:"login-password",children:"Mot de passe"}),r.jsx(j,{id:"login-password",type:"password",placeholder:"••••••••",value:n,onChange:t=>i(t.target.value),onKeyDown:t=>t.key==="Enter"&&u()})]}),r.jsx(R,{className:"w-full",variant:"solid",onClick:u,disabled:h,children:h?"Connexion...":"Se connecter"}),r.jsx("button",{type:"button",onClick:async()=>{if(!e){p({title:"Email requis",description:"Entrez votre email d'abord",variant:"destructive"});return}const{error:t}=await E.auth.resetPasswordForEmail(e,{redirectTo:`${window.location.origin}/reset-password`});t?p({title:"Erreur",description:t.message,variant:"destructive"}):p({title:"Email envoyé",description:"Vérifiez votre boîte mail pour réinitialiser votre mot de passe."})},className:"w-full text-sm text-muted-foreground hover:text-primary transition-colors",children:"Mot de passe oublié ?"}),r.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Vous êtes client ?"," ",r.jsx("a",{href:"/espace/connexion",className:"text-primary hover:underline",children:"Accéder à l'espace client"})]})]})]})})};export{ge 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.