简体   繁体   English

如何修改 nuxt 中的 $strapi.login({}) 默认路由(自定义登录)

[英]how to modify the $strapi.login({}) default route in nuxt(custom login)

I am using nuxt-strapi and I am authentication user by otp and for that I want to use $strapi.login() but the issue is the default endpoint for strapi login is auth/local which requires email and password but I want to modify it and use mobile number.我正在使用nuxt-strapi并且我是 otp 的身份验证用户,为此我想使用$strapi.login()但问题是strapi登录的默认端点是 auth/local 这需要 email 和密码,但我想修改它并使用手机号码。 I dont know how to modify the route for that so is there any option like in $auth I can modify the the login route我不知道如何为此修改路由,所以有没有像 $auth 这样的选项我可以修改登录路由

The nuxt-strapi module doesn't allow you to change the login URL. nuxt-strapi模块不允许您更改登录 URL。 What I would do in your case is directly call the OTP API endpoint and set the token manually.在您的情况下,我会直接调用 OTP API 端点并手动设置令牌。

const token = await this.$strapi.$http.$post('otp/endpoint', {tel}) 
await this.$strapi.setToken(token)
await this.$strapi.fetchUser() //to get the user information
//or get the user via $http and set it manually
this.$strapi.setUser(user)

see for more info https://strapi.nuxtjs.org/strapi查看更多信息https://strapi.nuxtjs.org/strapi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM