简体   繁体   中英

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. 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

The nuxt-strapi module doesn't allow you to change the login URL. What I would do in your case is directly call the OTP API endpoint and set the token manually.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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