how to redirect devise_for controller to other than default devise

核能气质少年 提交于 2019-12-24 19:05:15

问题


I have

devise_for :user, path: 'v1/user', class_name: "V1::User",controllers: {sessions: 'v1/sessions'

I like to have it redirect all not just sessions including :omniauth_callbacks to v1/sessions

or something like this

devise_for :user, path: 'v1/user', class_name: "V1::User",controllers: {sessions: 'v1/sessions'}, controllers: {omniauth_callbacks: 'v1/sessions'}

it will errors

warning: key :controllers is duplicated and overwritten on line 16


回答1:


As stated in my comment, you can just add another option to the controllers hash:

{ sessions: 'v1/sessions', omniauth_callbacks: 'v1/sessions' }




回答2:


Just include omniauth_callbacks key in the controller hash.

devise_for :user, path: 'v1/user', class_name: "V1::User",controllers: {sessions: 'v1/sessions', omniauth_callbacks: 'v1/sessions'}

Now your redirects for both email login and oauth login will be to v1/sessions



来源:https://stackoverflow.com/questions/58277724/how-to-redirect-devise-for-controller-to-other-than-default-devise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!