1import{a as m}from"./chunk-vendor-nuxt-image-CaOZiHYf.js";import{_ as I}from"./entry-entry-D2ersTkP.js";import{c as d,l as f,B as r,C as u,H as n,a9 as y,I as A,K as p}from"./chunk-vendor-runtime-B9_QDvFA.js";import"./chunk-vue-final-modal-C2MJ5Gxt.js";const C={class:"google-auth"},E={key:0,class:"google-auth__signin"},U=["disabled"],D={key:0},N={key:1},B={key:1,class:"google-auth__success"},T={class:"google-auth__user-info"},b=["src","alt"],G={class:"google-auth__user-details"},M={class:"google-auth__user-name"},z={class:"google-auth__user-email"},x={__name:"GoogleAuth",props:{clientId:{type:String,required:!0},onSuccess:{type:Function,default:()=>{}},onError:{type:Function,default:()=>{}}},setup(_){const l=_,g=d(!1),s=d({}),c=d(!1),h=d(null);f(()=>{const o=document.createElement("script");o.src="https://accounts.google.com/gsi/client",o.async=!0,o.defer=!0,o.onload=v,document.head.appendChild(o)});const v=()=>{var o,e;(e=(o=window.google)==null?void 0:o.accounts)!=null&&e.oauth2&&(h.value=window.google.accounts.oauth2.initTokenClient({client_id:l.clientId,scope:"email profile openid",callback:w,hint:l.loginHint||""}))},k=()=>{h.value&&(c.value=!0,h.value.requestAccessToken())},w=async o=>{if(o.access_token)try{const e=await fetch("https://www.googleapis.com/oauth2/v2/userinfo",{headers:{Authorization:`Bearer ${o.access_token}`}});if(e.ok){const t=await e.json();if(!t.email.toLowerCase().endsWith("@msp360.com")){c.value=!1,l.onError(new Error("Access denied. Only MSP360 employees can access this page.")),alert("Access denied. Only MSP360 employees can access this page.");return}s.value=t,g.value=!0,sessionStorage.setItem("googleAuthToken",o.access_token),sessionStorage.setItem("googleUserInfo",JSON.stringify(t));const{$cookies:i}=m(),a=[new Date(Date.now()+1e3*60*60*24*365*5),"/"];i.set("googleUserData",{fullName:t.name,email:t.email,picture:t.picture},...a),l.onSuccess({token:o.access_token,userInfo:t})}}catch(e){l.onError(e)}finally{c.value=!1}else c.value=!1,l.onError(new Error("No access token received"))},S=()=>{var e,t;g.value=!1,s.value={},sessionStorage.removeItem("googleAuthToken"),sessionStorage.removeItem("googleUserInfo");const{$cookies:o}=m();if(o.remove("googleUserData"),(t=(e=window.google)==null?void 0:e.accounts)!=null&&t.oauth2){const i=sessionStorage.getItem("googleAuthToken");i&&window.google.accounts.oauth2.revoke(i)}};return f(()=>{const o=sessionStorage.getItem("googleAuthToken"),e=sessionStorage.getItem("googleUserInfo");if(o&&e){const t=JSON.parse(e);if(!t.email.toLowerCase().endsWith("@msp360.com")){sessionStorage.removeItem("googleAuthToken"),sessionStorage.removeItem("googleUserInfo");return}s.value=t,g.value=!0}else{const{$cookies:t}=m(),i=t.get("googleUserData");if(i)try{const a=i;if(!a.email.toLowerCase().endsWith("@msp360.com")){t.remove("googleUserData");return}s.value={name:a.fullName||a.name,email:a.email,picture:a.picture},g.value=!0}catch{}}}),(o,e)=>(u(),r("div",C,[g.value?(u(),r("div",B,[n("div",T,[s.value.picture?(u(),r("img",{key:0,src:s.value.picture,alt:s.value.name,class:"google-auth__avatar"},null,8,b)):A("",!0),n("div",G,[n("p",M,p(s.value.name),1),n("p",z,p(s.value.email),1)])]),n("button",{onClick:S,class:"google-auth__signout-button"}," Sign out ")])):(u(),r("div",E,[e[1]||(e[1]=n("h3",{class:"google-auth__title"},"Sign in with Google",-1)),e[2]||(e[2]=n("p",{class:"google-auth__description"},"Please sign in with your Google account to continue",-1)),n("button",{onClick:k,class:"google-auth__button",disabled:c.value},[e[0]||(e[0]=y('<svg class="google-auth__icon" viewBox="0 0 24 24" width="18" height="18" data-v-4326fa92><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" data-v-4326fa92></path><path fill="#34A853" 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" data-v-4326fa92></path><path fill="#FBBC05" 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" data-v-4326fa92></path><path fill="#EA4335" 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" data-v-4326fa92></path></svg>',1)),c.value?(u(),r("span",D,"Signing in...")):(u(),r("span",N,"Sign in with Google"))],8,U)]))]))}},$=I(x,[["__scopeId","data-v-4326fa92"]]);export{$ 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.