Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

authentication - Nuxt Auth & Laravel Sanctum - "remember me" option does not work

I suspect this is the "fault" of NuxtJS Auth, because remember_tokens are stored in the database. I don't know how to deal with it. I am always logged out after a few hours.

auth: {
    strategies: {
        'laravelSanctum': {
            provider: 'laravel/sanctum',
            url: 'https://api.mydomain.com',
            endpoints: {
                login: { url: '/auth/login', method: 'post' },
                logout: { url: '/auth/logout', method: 'post' },
                user: { url: '/auth/user', method: 'get' }
            }
        }
    }
},

What can I do to fix it?

@edit

auth: {
        cookie: {
            prefix: 'auth.',
            options: {
                path: '/',
                domain: process.env.COOKIES_DOMAIN,
                expires: 365,
                maxAge: 31536000000, // 365 days
                secure: true,
            }
        },
        strategies: {
            'laravelSanctum': {
                provider: 'laravel/sanctum',
                url: process.env.API_URL,
                endpoints: {
                    login: { url: '/auth/login', method: 'post' },
                    logout: { url: '/auth/logout', method: 'post' },
                    user: { url: '/auth/user', method: 'get' }
                },
            }
        }
    },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In fact, Laravel "remember" feature not used in Nuxt Auth module. It's just cookie expires, so you should create cookie with veeeery long expiration.

More about this and solution you can find here: https://paigejones.me/nuxt-auth-remember-me


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...