重写Nuxt.js身份验证模块's策略参数



是否有方法覆盖Nuxt.js身份验证模块的策略配置?例如,我可以将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> },
})

最新更新