我正在尝试使用设计进行ajax登录,但我似乎无法使其工作.问题是我在设计上启用了确认策略,warden.authenticate!应该在非活动用户上失败并呈现failure
操作,而是呈现默认操作.我注意到很多教程都有相同的设置.我正在使用rails 4.0.0并设计3.2.2.
class SessionsController < Devise::SessionsController
def create
#problem: failure not getting called
resource = warden.authenticate!(scope: resource_name, recall: "#{controller_path}#failure")
sign_in(resource_name, resource)
render json: {success: true}
end
def failure
render json: {success: false, errors: ["Login failed!"]}
end
end
Run Code Online (Sandbox Code Playgroud)
devise.rb设置如下,
config.http_authenticatable_on_xhr = false
config.navigational_formats = ['*/*', :'*/*', :html, :json]
Run Code Online (Sandbox Code Playgroud)
routes.rb具有以下内容,
devise_for :users, controllers: {registrations: "registrations", sessions: "sessions"}
Run Code Online (Sandbox Code Playgroud)
登录表格,
<%= form_for(resource, as: resource_name,
url: session_path(resource_name),
format: :json,
html:{id:"signin_form"},
remote: true) do |f| %>
<%= f.label(:email, "Email") %>
<%= f.text_field(:email, class: "field …
Run Code Online (Sandbox Code Playgroud) 我尝试将SIGTSTP信号发送到特定进程,但是如何确定进程是否在Linux中使用C库函数或系统调用实际上已暂停?