nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 924 forks source link

Store token without prefix and postfix #1431

Closed keksum666 closed 2 years ago

keksum666 commented 2 years ago

Hi, is it possible to store an authorization token with the name 'token' without prefix and postfix. With the "cookie" authorization scheme, the token is stored with the following name: "auth.token.cookie", I would like it to be stored in with the name "token". Thanks

keksum666 commented 2 years ago

The problem is solved as follows:

auth: {
        localStorage: false,
        cookie: {
            prefix: '',
            options: {
                domain: process.env.APP_DOMAIN
            }
        },
        strategies: {
            token: {
                scheme: 'cookie',
                token: {
                    property: 'token',
                    prefix: '',
                    global: true,
                    required: true,
                    type: 'Bearer',
                },
                user: {
                    autoFetch: true,
                    property: false,
                },
                endpoints: {
                    login: { url: '/login', method: 'post', propertyName: 'token' },
                    logout: { url: '/auth/logout', method: 'post' },
                    user: { url: '/auth/user', method: 'get' },
                }
            }
        }
    }