PageSourceSearch

https://app.ctrlgrow.com/assets/client-sso-6dc8ab22.js

js ctrlgrow.com collected 2026-10-05 21:43:53 UTC 7,126 bytes, 1 lines download raw bytes

1import{_ as e}from"./AppTextField-38baa2bf.js";import{ci as a,l as t,z as l,U as n,e7 as o,o as r,c as u,q as i,B as s,aH as c,al as d,s as m,e3 as v,n as p,w as f,b as h,aI as y,M as w,v as _,a$ as g,D as b,C as k,ab as $,F as x,a7 as S}from"./index-94ffe496.js";import{r as q,e as C}from"./validators-42fae42e.js";import{b as V}from"./route-block-83d24a4e.js";import{V as U,a as R}from"./VRow-997c6631.js";const j={class:"client-sso-page bg-surface"},A=p("h5",{class:"text-h5 mb-1"}," Sign in to continue ",-1),L={class:"mb-0"},P=["action"],T=["value"],E=["value"],I=p("div",{class:"mt-3 text-body-2"}," Checking your session... ",-1),W=["value"],N=["value"],z={class:"saved-account text-center mb-4"},D={class:"saved-account__name"},F={class:"saved-account__email"},O={__name:"client-sso",setup(V){const O=a(),B=t(!1),G=t(""),Y=t(""),H=t(""),J=t(null),K=t(!1),M=t(""),Q=t(!0),X=t(""),Z=l(()=>"https://api.ctrlgrow.com".replace(/\/$/,"")),ee=l(()=>`${Z.value}/login`),ae=l(()=>`${Z.value}/login/csrf-token`),te=l(()=>`${Z.value}/login/session`),le=l(()=>{const e=Array.isArray(O.query.return_to)?O.query.return_to[0]:O.query.return_to;if(!e)return!1;try{return"1"===new URL(String(e),window.location.origin).searchParams.get("sso_continue_attempt")}catch{return!1}}),ne=l(()=>(e=>{const a=Array.isArray(e)?e[0]:e,t=String(a||"/").trim();if(!t||t.startsWith("//"))return"/";try{const e=new URL(t,window.location.origin),a=new URL(Z.value),l=e.origin===window.location.origin,n=e.hostname===a.hostname&&"/oauth/authorize"===e.pathname;return l||n?("select_account"===e.searchParams.get("prompt")&&e.searchParams.delete("prompt"),e.searchParams.delete("sso_continue_attempt"),l?`${e.pathname}${e.search}${e.hash}`||"/":`${Z.value}${e.pathname}${e.search}${e.hash}`):"/"}catch{return"/"}})(O.query.return_to)),oe=l(()=>ne.value.startsWith("/oauth/authorize")?`${Z.value}${ne.value}`:ne.value),re=l(()=>String(O.query.email||G.value||"")),ue=l(()=>"1"===O.query.otp_required),ie=l(()=>{var e,a;return(null==(e=J.value)?void 0:e.fullName)||(null==(a=J.value)?void 0:a.email)||"your account"}),se=l(()=>{switch(O.query.error){case"invalid_credentials":return"Email or password is incorrect.";case"invalid_otp":return"The verification code is incorrect.";case"otp_expired":return"The verification code expired. Sign in again to get a new code.";case"otp_locked":return"Too many incorrect codes. Sign in again to get a new code.";default:return""}}),ce=()=>{K.value=!1,J.value=null,X.value="",G.value="",Y.value="",H.value=""},de=()=>{window.location.href=`${window.location.pathname}?return_to=${encodeURIComponent(ne.value)}`},me=()=>{const e=new URL(oe.value,window.location.origin);e.searchParams.set("sso_continue_attempt","1"),window.location.href=e.toString()},ve=async()=>{if(M.value)return!0;try{return await(async()=>{const e=await fetch(ae.value,{headers:{Accept:"application/json"},credentials:"include"});if(!e.ok)throw new Error(`CSRF token request failed with ${e.status}`);const a=await e.json();M.value=a.csrf_token||""})(),Boolean(M.value)}catch(e){return!1}},pe=e=>!!(null==e?void 0:e.email)&&(J.value={email:e.email,fullName:e.fullName||e.name||e.email},G.value=e.email,!0),fe=async e=>{if(!M.value)return e.preventDefault(),void(await ve()&&e.target.requestSubmit())};return n(()=>{if(ve(),ue.value)Q.value=!1;else{try{const e=localStorage.getItem("userData")||localStorage.getItem(o);e&&pe(JSON.parse(e))}catch{J.value=null,K.value=!1}if(le.value)return K.value=!1,Q.value=!1,void(X.value="Your session has expired. Sign in again to continue.");(async()=>{try{const e=await fetch(te.value,{headers:{Accept:"application/json"},credentials:"include",cache:"no-store"});if(!e.ok)throw new Error(`Session status request failed with ${e.status}`);const a=await e.json();if(a.authenticated&&pe(a.account))return void(K.value=!0);K.value=!1,J.value&&(G.value=J.value.email,X.value="Your session has expired. Sign in again to continue.")}catch(e){K.value=!1,J.value&&(G.value=J.value.email),X.value="We could not verify your session. Sign in again to continue."}finally{Q.value=!1}})()}}),(a,t)=>{const l=e;return r(),u("div",j,[i(S,{"max-width":440,class:"client-sso-card pa-4"},{default:s(()=>[i(c,{class:"text-center pb-2"},{default:s(()=>[i(d,{src:m(v),alt:"CTRL+GROW",class:"mx-auto mb-6","max-width":"190"},null,8,["src"]),A,p("p",L,f(m(ue)?`Enter the code sent to ${m(re)}.`:"Use your CTRL+GROW account credentials."),1)]),_:1}),i(c,null,{default:s(()=>[m(X)?(r(),h(y,{key:0,class:"mb-4",color:"info",variant:"tonal"},{default:s(()=>[w(f(m(X)),1)]),_:1})):_("",!0),m(se)?(r(),h(y,{key:1,class:"mb-4",color:"error",variant:"tonal"},{default:s(()=>[w(f(m(se)),1)]),_:1})):_("",!0),p("form",{action:m(ee),method:"post",autocomplete:"off",onSubmit:fe},[p("input",{type:"hidden",name:"_token",value:m(M)},null,8,T),p("input",{type:"hidden",name:"return_to",value:m(ne)},null,8,E),i(U,null,{default:s(()=>[m(Q)?(r(),h(R,{key:0,cols:"12",class:"text-center py-8"},{default:s(()=>[i(g,{indeterminate:"",color:"primary"}),I]),_:1})):_("",!0),m(ue)?(r(),h(R,{key:1,cols:"12"},{default:s(()=>[p("input",{type:"hidden",name:"email",value:m(re)},null,8,W),i(l,{modelValue:m(H),"onUpdate:modelValue":t[0]||(t[0]=e=>b(H)?H.value=e:null),name:"otp",label:"Verification code",inputmode:"numeric",maxlength:"6",autofocus:"",required:"",autocomplete:"one-time-code",rules:[m(q)]},null,8,["modelValue","rules"]),i(k,{block:"",type:"submit",class:"mt-6"},{default:s(()=>[w(" Verify code ")]),_:1}),i(k,{block:"",type:"button",variant:"outlined",class:"mt-2",onClick:de},{default:s(()=>[w(" Sign in again ")]),_:1})]),_:1})):!m(Q)&&m(K)&&m(J)?(r(),h(R,{key:2,cols:"12"},{default:s(()=>[p("input",{type:"hidden",name:"email",value:m(J).email},null,8,N),p("div",z,[p("div",D,f(m(ie)),1),p("div",F,f(m(J).email),1)]),i(k,{block:"",type:"button",class:"mt-2 text-body-1",onClick:me},{default:s(()=>[w(" Continue as "+f(m(ie)),1)]),_:1}),i(k,{block:"",variant:"outlined",class:"mt-2 text-body-1",onClick:$(ce,["prevent"])},{default:s(()=>[w(" Use another account ")]),_:1},8,["onClick"])]),_:1})):m(Q)?_("",!0):(r(),u(x,{key:3},[i(R,{cols:"12"},{default:s(()=>[i(l,{modelValue:m(G),"onUpdate:modelValue":t[1]||(t[1]=e=>b(G)?G.value=e:null),name:"email",label:"Email",type:"email",autofocus:"",required:"",autocomplete:"off",rules:[m(q),m(C)]},null,8,["modelValue","rules"])]),_:1}),i(R,{cols:"12"},{default:s(()=>[i(l,{modelValue:m(Y),"onUpdate:modelValue":t[2]||(t[2]=e=>b(Y)?Y.value=e:null),name:"password",label:"Password",required:"",autocomplete:"new-password",rules:[m(q)],type:m(B)?"text":"password","append-inner-icon":m(B)?"tabler-eye-off":"tabler-eye","onClick:appendInner":t[3]||(t[3]=e=>B.value=!m(B))},null,8,["modelValue","rules","type","append-inner-icon"]),i(k,{block:"",type:"submit",class:"mt-6"},{default:s(()=>[w(f(m(J)?`Sign in again as ${m(ie)}`:"Continue"),1)]),_:1}),m(J)?(r(),h(k,{key:0,block:"",type:"button",variant:"outlined",class:"mt-2",onClick:ce},{default:s(()=>[w(" Use another account ")]),_:1})):_("",!0)]),_:1})],64))]),_:1})],40,P)]),_:1})]),_:1})])}}};"function"==typeof V&&V(O);export{O 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.