覆盖 Nuxt.js auth 模块的策略参数
Override Nuxt.js auth module's strategies parameters
有没有办法覆盖 Nuxt.js auth 模块的策略配置?例如,我可以将 redirect_uri
参数从 nuxt.config.js
移动到 pages/index.vue
中的方法吗?
nuxt.config.js
中的身份验证配置:
auth: {
strategies: {
'laravel.passport': {
url: 'http://laravel.test',
client_id: 2,
client_secret: 'S0gpcgfIDgbvIHCL3jIhSICAiTsTUMOR0k5mdaCi',
redirect_uri: 'http://localhost:3000'
}
}
}
pages/index.vue
中的登录方法:
async login () {
await this.$auth.loginWith('laravel.passport', {
data: {
// All the 3 parameters below don't seem to be taken into account.
username: 'me@home.com',
password: '1qaz@WSX',
// If 'redirect_uri' is removed from 'nuxt.config.js'
// and moved below, logging in returns an error.
redirect_uri: 'http://localhost:3000'
}
}).then((r) => {
console.log(r)
}).catch((e) => {
console.log(e)
})
}
this.$auth
.loginWith(<yourStrategy>, {
params: { redirect_uri: <youURI> },
})
有没有办法覆盖 Nuxt.js auth 模块的策略配置?例如,我可以将 redirect_uri
参数从 nuxt.config.js
移动到 pages/index.vue
中的方法吗?
nuxt.config.js
中的身份验证配置:
auth: {
strategies: {
'laravel.passport': {
url: 'http://laravel.test',
client_id: 2,
client_secret: 'S0gpcgfIDgbvIHCL3jIhSICAiTsTUMOR0k5mdaCi',
redirect_uri: 'http://localhost:3000'
}
}
}
pages/index.vue
中的登录方法:
async login () {
await this.$auth.loginWith('laravel.passport', {
data: {
// All the 3 parameters below don't seem to be taken into account.
username: 'me@home.com',
password: '1qaz@WSX',
// If 'redirect_uri' is removed from 'nuxt.config.js'
// and moved below, logging in returns an error.
redirect_uri: 'http://localhost:3000'
}
}).then((r) => {
console.log(r)
}).catch((e) => {
console.log(e)
})
}
this.$auth
.loginWith(<yourStrategy>, {
params: { redirect_uri: <youURI> },
})