PageSourceSearch

https://www.gooyadubai.ae/_nuxt/I5z846HX.js

js gooyadubai.ae collected 2026-09-24 14:29:25 UTC 4,216 bytes, 1 lines download raw bytes

1import{ax as L,r as T,n as w}from"./-DLWNC6n.js";import{e as S}from"./poOW0nuE.js";import{y as U,a as x,n as g,k as O,F,a1 as q,u as B,p as $,i as z}from"#entry";import{l as D}from"./C90W3vFq.js";import{r as p}from"./CfVdlt2c.js";import{a as A}from"./KXDfhFVj.js";import{u as H}from"./BX4v9dxa.js";const k="gooya:auth-back-home-once";function J(){const n=U(),i=x();function h(){{if(sessionStorage.getItem(k)==="1"){sessionStorage.removeItem(k),g(i("/"));return}const c=window.history.state;if(c!=null&&c.back!=null&&c.back!==""){n.back();return}}g(i("/"))}return{goAuthBack:h}}let d=null;function V(){const n=O(),i=F(),h=L(),c=H(),{syncFromProfileApi:m}=q(),C=z(),{locale:y}=B(),u=T(!1),f=T(null);function s(r,o,e){return String(y.value)==="ar"?A(o)||A(r):String(y.value)==="en"?o:r}async function E(r,o){u.value=!0,f.value=null;try{const e=await $fetch("/api/auth/login/",{method:"POST",body:{username:r.identifier.trim(),password:r.password}}),t=e.tokens?.access||e.access||"",a=e.tokens?.refresh||e.refresh||"";if(!t||!a)throw new Error(s("توکن احراز هویت دریافت نشد","Authentication token was not received"));n.setTokens(t,a),e.user&&n.setUser(e.user),await m({force:!0}),i.addToast({type:"success",title:s("خوش آمدید","Welcome")}),await w();const l=p(n,o);await g(c(l),{replace:!0})}catch(e){const t=D(e);f.value=t,i.addToast({type:"error",title:s("خطا","Error"),description:t})}finally{u.value=!1}}async function b(r,o){u.value=!0,f.value=null;try{const e=await $fetch("/api/auth/register/",{method:"POST",body:r}),t=e.tokens?.access||e.access||"",a=e.tokens?.refresh||e.refresh||"";if(t&&a&&n.setTokens(t,a),e.user&&n.setUser(e.user),i.addToast({type:"success",title:s("ثبت‌نام موفق","Registration successful")}),await w(),t&&a){await m({force:!0});const l=p(n,o);await g(c(l),{replace:!0})}else await g(c(o||"/"),{replace:!0})}catch(e){const t=S(e).message;f.value=t,i.addToast({type:"error",title:s("خطا","Error"),description:t})}finally{u.value=!1}}function P(){return window.google?.accounts?Promise.resolve():d||(d=new Promise((r,o)=>{const e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.async=!0,e.defer=!0,e.onload=()=>r(),e.onerror=()=>o(new Error(s("بارگذاری سرویس گوگل ناموفق بود","Google sign-in service failed to load"))),document.head.appendChild(e)}),d)}async function _(){const r=String(C.public.googleClientId||"").trim();if(!r)throw new Error(s("Google Client ID تنظیم نشده است","Google Client ID is not configured"));await P();const o=window.google;if(!o?.accounts?.oauth2?.initTokenClient)throw new Error(s("سرویس ورود گوگل در دسترس نیست","Google sign-in service is not available"));return await new Promise((e,t)=>{o.accounts.oauth2.initTokenClient({client_id:r,scope:"openid email profile",callback:l=>{if(!l||l.error){t(new Error(s("دریافت توکن گوگل ناموفق بود","Failed to receive Google token")));return}const v=String(l.access_token||"").trim();if(!v){t(new Error(s("توکن گوگل خالی است","Google token is empty")));return}e(v)}}).requestAccessToken({prompt:"select_account"})})}async function G(r){u.value=!0,f.value=null;try{const o=await _(),e=await $fetch("/api/auth/social/google/",{method:"POST",body:{access_token:o,platform:"web",redirect_uri:window.location.origin}}),t=e.tokens?.access||e.access||"",a=e.tokens?.refresh||e.refresh||"";if(!t||!a)throw new Error(s("توکن احراز هویت دریافت نشد","Authentication token was not received"));n.setTokens(t,a),e.user&&n.setUser(e.user),await m({force:!0}),i.addToast({type:"success",title:s("ورود با گوگل انجام شد","Signed in with Google")}),await w();const l=p(n,r);return await g(c(l),{replace:!0}),!0}catch(o){const e=S(o).message;return f.value=e,i.addToast({type:"error",title:s("خطا","Error"),description:e}),!1}finally{u.value=!1}}async function I(){try{const r=$("refresh_token").value}catch{}finally{n.clearAuth(),h.clear(),sessionStorage.setItem(k,"1"),await g(c("/auth/required-login"),{replace:!0})}}return{login:E,register:b,loginWithGoogle:G,logout:I,isLoading:u,error:f}}export{V as a,J as u};

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.