Devise authentication as API only

不打扰是莪最后的温柔 提交于 2019-12-08 06:35:57

问题


I'm trying to use Devise authentication with Angular.js. Everything is already working except I want to hide the server-side login form, i.e. the result of /users/sign_in GET request leaving only the possibility of /users/sign_in POST request. Is this possible?


回答1:


I think you'll need to skip sessions in your devise_for call in routes.rb (or not even call it) and just stick to devise_scope for setting up your sign_in path. So, your routes.rb would look like this:

devise_for :users, :skip => :sessions

devise_scope do
  post "/users/sign_in" => "devise/sessions#create"
  delete "/users/sign_out" => "devise/sessions#destroy"
end


来源:https://stackoverflow.com/questions/14728211/devise-authentication-as-api-only

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