Problems with login which is correct

first of all, thank you all for the amazing work of $$F7.

I’m facing a problem on the login screen I don’t know if I’m doing it correctly, I’ve tried several ways and I still face one problem or another.

my problem here is whenever I reload the page it displays the login screen and then goes back to the current screen.

Senary:
index.html → auth login screen
pages/dashboard.html - home screen

Whenever I reload a screen it displays the login screen along with the authentication.

Router file:

var routes = [
  {
    name: "login",
    path: '/',
    // url: './index.html',
    async: async function ({ app, to, form, resolve, reject }) {
      let router = this
       const login = await MODEL.checkSession()
      
      if (login.data.auth) {
        $('#load').css({ "display": "none" })
        resolve({ url: './pages/dasboard.html' })
      } else {
        $('#load').css({ "display": "none" })
        resolve({ url: './index.html' })
        reject();
      }
  },
  {
    name: 'dashboard',
    path: '/dashboard/',
    // url: './pages/dashboard.html',
    async: async function ({ app, to, form, resolve, reject }) {
      let router = this
      const login = await MODEL.checkSession()
      if (login.data.auth) {
        resolve({ url: './pages/dashboard.html' })
      } else {
        // resolve({url: './index.html'})
        $('#load').css({ "display": "none" })

        reject();
        router.navigate('/');
      }
  },

my doubt is how can I work with the login correctly so that it doesn’t reload the login page before, thank you all.
debug movie: test.mov - Google Drive

Good morning, get a solution after 2 weeks trying, I will share what I did for the next doubt and leave it open for an example of the best way to use it.

Creating login screen with Framework7

index.html - Load {page load}
/pages/login - login page
/pages/dashboard - home page

var routes = [
{
name: "load",
path: '/',
// url: './index.html',
async: async function ({ app, to, form, resolve, reject }) {
let router = this
const login = await MODEL.checkSession()
   if (login.data.auth) {
     resolve({ url: './pages/dasboard.html' })
   } else {
     resolve({ url: './login.html' })
     reject();
   }
},
...

Would this be the correct way or the best way to work with login?

thanks

1 Like