UNPKG

@accounter/client

Version:
1 lines 2.27 kB
import{Cd as e,Cu as t,Du as n,Id as r,Wl as i,bd as a,jd as o,t as s,wd as c}from"./index-CSYTUOOk.js";var l=r(o(),1);function u(){try{let e=[`@@auth0spajs@@`,`a0.spajs.txs`],t=[`auth0.is.authenticated`];Object.keys(localStorage).filter(n=>t.includes(n)||e.some(e=>n.startsWith(e))).map(e=>localStorage.removeItem(e))}catch{}}var d=t();function f(){let{loginWithRedirect:t,isAuthenticated:r,isLoading:o}=a(),f=c(),p=e(),m=new URLSearchParams(p.search),h=m.get(`reauth`)===`1`,g=p.state?.returnTo??(h?sessionStorage.getItem(`auth:invitationReturnTo`):null)??n.HOME,_=m.get(`error`),v=_?_===`auth_failed`?`Authentication failed. Please try again.`:s[_]??_:h?`Your session expired. Please sign in again.`:null;return(0,l.useEffect)(()=>{!o&&r&&!h&&f(g,{replace:!0})},[r,o,h,f,g]),(0,l.useEffect)(()=>{localStorage.removeItem(`user`),h&&u()},[h]),(0,d.jsxs)(`div`,{className:`w-full flex flex-col justify-center items-center h-screen lg:grid lg:min-h-[200px] lg:grid-cols-2 xl:min-h-screen`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsxs)(`div`,{className:`space-y-8 w-[320px]`,children:[(0,d.jsxs)(`div`,{className:`grid gap-2 text-center`,children:[(0,d.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Accounter`}),(0,d.jsx)(`h2`,{className:`text-3xl font-bold`,children:`Sign In`}),(0,d.jsx)(`p`,{className:`text-balance text-muted-foreground`,children:`Use your Auth0 account to continue`}),v?(0,d.jsx)(`p`,{className:`text-sm text-destructive`,children:v}):null]}),(0,d.jsx)(i,{onClick:()=>((!h||!sessionStorage.getItem(`auth:returnTo`))&&sessionStorage.setItem(`auth:returnTo`,g),t({authorizationParams:{audience:void 0,scope:`openid profile email offline_access`,...h?{prompt:`login`}:{},redirect_uri:`${window.location.origin}${n.AUTH_CALLBACK}`},appState:{returnTo:g}})),className:`w-full font-semibold`,disabled:o,children:o?`Preparing sign in...`:`Continue with Auth0`})]})}),(0,d.jsx)(`div`,{className:`hidden bg-muted lg:block bg-black rounded-tl-3xl rounded-bl-3xl`,children:(0,d.jsx)(`div`,{className:`flex flex-row justify-center items-center h-screen`,children:(0,d.jsx)(`img`,{src:`../../icons/guild-logo.svg`,alt:`Guild logo`,className:`w-[100px] h-[100px] object-cover`})})})]})}export{f as LoginPage};