ItalyPaleAle / svelte-spa-router

Router for SPAs using Svelte 3
MIT License
1.55k stars 106 forks source link

If I want to go to the login page in the sidebar + SPA form, is it possible with route guard? #297

Closed Neptunium1129 closed 1 year ago

Neptunium1129 commented 1 year ago

my sidebar example

https://sophana.github.io/svelte-spa-router-sidebar/docs/

It is very similar based on this project

image

image

but When logging out, the login page appears within a slot instead of appearing standalone.

Is it possible to transition to the LoginPage when logging out?

ItalyPaleAle commented 1 year ago

Nice, thanks for sharing @Neptunium1129 ! Glad I could be of help :)

PS: Because there's no action for me to do on this issue, I'm going to close it for now

ItalyPaleAle commented 1 year ago

I see the images now, reopening

ItalyPaleAle commented 1 year ago

In order to answer this:

but When logging out, the login page appears within a slot instead of appearing standalone.

Is it possible to transition to the LoginPage when logging out?

Would need more information on the app and how it's built

Neptunium1129 commented 1 year ago

image

{#if sessionCheck == false}
  <!-- content here -->
  <NmsLogin on:sessionCheck={fnSessionCheck}></NmsLogin>
{:else}
  <!-- else content here -->
  {#await fnLoginCheckAxios()}
      <div>LOGIN...</div>
  {:then res}
    {#if res.data.data.customerYn=="Y"}
        <NmsCustMain on:sessionCheck={fnSessionCheck} {fnSessionCheck} loginUser={res.data.data}>
        <span slot="content">
            <Router {routes} >
            </Router>
        </span>
        </NmsCustMain>
    {:else}
        <NmsMain on:sessionCheck={fnSessionCheck} loginUser={res}}>
            <span slot="content">
                <Router {routes} >
                </Router>
            </span>
        </NmsMain>
    {/if}
  {:catch error}
      <div>LOGIN FAIL...</div>
  {/await}
{/if}

When the logout button is clicked, the user is directed to a standalone page. However, if authentication is interrupted in the middle, the login page is displayed within a slot.