nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
96 stars 20 forks source link

Redirect doesn't work after login #3

Closed 93lucasp closed 7 months ago

93lucasp commented 1 year ago

This is the code:

auth: {
    globalMiddleware:true,
    strategies: {
      local: {
        scheme: 'refresh',
        token: {
          property: 'accessToken',
          maxAge: 1800,
          // required: true,
          // type: 'Bearer'
        },
        refreshToken: {
          property: 'refreshToken',
          data: 'refreshToken',
          maxAge: 3600
        },
        user: {
          property: false,
          // autoFetch: true
        },
        endpoints: {
          login: { url: '', method: 'post' },
          refresh: { url: '', method: 'post' },
          logout: { url: '', method: 'post' },
          user: { url: '', method: 'get' }
        }
      }
    },

    redirect: {
      login: '/login',
      logout: '/login',
      home: '/',
    },
  },
const loginFun = async function () {
  await $auth.loginWith("local", {
    body: { username: "username", password: "password" },
  });
};

If I refresh the page is going to the correct page, but it doesn't go automatically after the login function.

After the logout function yes!

amery commented 1 year ago

is there a working example of globalMiddleware: true. I don't get redirect after login unless I navigateTo() on .then(), and whenever I open a page I get redirected back to login even when the user's /auth/me works fine

93lucasp commented 7 months ago

@Denoder do you have some update on this?

Denoder commented 7 months ago

does this only happen with global middleware?