5858 </ sidebar-layout >
5959 < main class ="lg:pl-72 ">
6060 < div v-if ="init " class ="px-4 sm:px-6 lg:px-8 ">
61- < sign-in v-if ="!user "> </ sign-in >
61+ < div v-if ="!user ">
62+ < sign-in > </ sign-in >
63+ </ div >
6264 < div v-else >
6365 < h1 class ="hidden lg:block pt-4 mb-2 text-3xl font-bold leading-tight tracking-tight text-gray-900 "> {{ activeSection.title }}</ h1 >
6466 < component :key ="refreshKey " :is ="activeSection.component " @nav ="navTo " :type ="activeSection.type "> </ component >
@@ -69,7 +71,7 @@ <h1 class="hidden lg:block pt-4 mb-2 text-3xl font-bold leading-tight tracking-t
6971
7072< script type ="module ">
7173import { createApp , ref , onMounted , shallowRef } from "vue"
72- import { JsonApiClient , leftPart , rightPart , appendQueryString , humanize } from "@servicestack/client"
74+ import { JsonApiClient , leftPart , rightPart , appendQueryString , humanize , queryString } from "@servicestack/client"
7375import ServiceStackVue , { useClient , useAuth , useMetadata } from "@servicestack/vue"
7476import { Authenticate , AdminData } from "dtos.mjs"
7577import * as Sections from "./sections/index.mjs"
@@ -167,10 +169,28 @@ <h2 class="mt-4 text-3xl sm:text-4xl text-slate-900 font-extrabold tracking-tigh
167169 window . addEventListener ( 'popstate' , event => {
168170 navTo ( event . state ?. section || getSection ( ) , { } , false )
169171 } )
172+
173+ // Auto Sign In ?user=...&pass=...
174+ if ( location . search ) {
175+ const q = queryString ( location . search )
176+ if ( q . user && q . pass ) {
177+ const api = await client . api ( new Authenticate ( {
178+ provider : 'credentials' ,
179+ userName : q . user ,
180+ password : q . pass ,
181+ } ) )
182+ if ( api . succeeded ) {
183+ signIn ( api . response )
184+ history . replaceState ( { } , null , leftPart ( location . href , '?' ) )
185+ }
186+ }
187+ }
170188
171- const api = await client . api ( new Authenticate ( ) )
172- if ( api . succeeded ) {
173- signIn ( api . response )
189+ if ( ! user . value ) {
190+ const api = await client . api ( new Authenticate ( ) )
191+ if ( api . succeeded ) {
192+ signIn ( api . response )
193+ }
174194 }
175195 init . value = true
176196 } )
0 commit comments