warden.authenticate!(auth_options) returns 无
warden.authenticate!(auth_options) returns nil
Rails 5.1。你好。目前我们的应用程序已经实现了一个身份验证系统,我们将迁移到设计中。我在这里无能为力试图让设计登录 work.Here 是自定义代码 sessions_controller
class Users::SessionsController < Devise::SessionsController
include ExpireExistingToken
def new
super
end
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message!(:notice, :signed_in)
sign_in(resource_name, resource)
yield resource if block_given?
resource.update(language: Constant::SUPPORTED_LANGUAGES.key(params['locale'])) if params['locale'].present?
resource.send_otp(force_expire: true) if resource.email_verified?
respond_with resource, location: after_sign_in_path_for(resource)
flash.delete(:notice)
end
def destroy
session.delete(:is_otp_verified)
super
end
end
auth_options
{:scope=>:user, :recall=>"users/sessions#new"}
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
An unauthorized connection attempt was rejected
Processing by Users::SessionsController#new as HTML
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Parameters: {"utf8"=>"✓", "authenticity_token"=>"wP84hj41ml3YlPaJpTBfnT985MSSpEkbaOvvQaNvxwesoSe19JWobaD4IQEZrm6btpWgJ5vldd9E0VzmsOIV5Q==", "user"=>{"email"=>"user12@gmail.com", "password"=>"[FILTERED]"}, "button"=>"", "locale"=>"en"}
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
An unauthorized connection attempt was rejected
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
Rendering devise/sessions/new.html.haml within layouts/pre_authentication
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Rendered devise/sessions/new.html.haml within layouts/pre_authentication (3.7ms)
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
Rendered shared/_flash.haml (2.0ms)
Rendered shared/_language_selector.html.haml (2.9ms)
Completed 200 OK in 159ms (Views: 30.1ms | ActiveRecord: 0.0ms)
这里的问题是 warden.authenticate!(auth_options) returns 没有。我检查了我的其他更简单的应用程序并验证了扫描数据库的行为,无论 email/password 是否正确。我如何让 Warden/Devise 实际执行 select 语句来检查数据库?
这是定义的路线 -
scope 'web' do
scope '/:locale' do
devise_for :users, controllers: {
passwords: 'users/passwords',
sessions: 'users/sessions',
registrations: 'users/registrations'
}
end
end
(如果有什么可以贴出来帮助大家的我会贴出来的)
看起来问题出在 /cable
操作上,它以某种方式阻止 current authentication
进程或操作完成。您可以通过在您的应用中评论 /cable
来验证这一点。
Rails 5.1。你好。目前我们的应用程序已经实现了一个身份验证系统,我们将迁移到设计中。我在这里无能为力试图让设计登录 work.Here 是自定义代码 sessions_controller
class Users::SessionsController < Devise::SessionsController
include ExpireExistingToken
def new
super
end
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message!(:notice, :signed_in)
sign_in(resource_name, resource)
yield resource if block_given?
resource.update(language: Constant::SUPPORTED_LANGUAGES.key(params['locale'])) if params['locale'].present?
resource.send_otp(force_expire: true) if resource.email_verified?
respond_with resource, location: after_sign_in_path_for(resource)
flash.delete(:notice)
end
def destroy
session.delete(:is_otp_verified)
super
end
end
auth_options
{:scope=>:user, :recall=>"users/sessions#new"}
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
An unauthorized connection attempt was rejected
Processing by Users::SessionsController#new as HTML
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Parameters: {"utf8"=>"✓", "authenticity_token"=>"wP84hj41ml3YlPaJpTBfnT985MSSpEkbaOvvQaNvxwesoSe19JWobaD4IQEZrm6btpWgJ5vldd9E0VzmsOIV5Q==", "user"=>{"email"=>"user12@gmail.com", "password"=>"[FILTERED]"}, "button"=>"", "locale"=>"en"}
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
An unauthorized connection attempt was rejected
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
Rendering devise/sessions/new.html.haml within layouts/pre_authentication
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Rendered devise/sessions/new.html.haml within layouts/pre_authentication (3.7ms)
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2021-01-27 16:07:46 +0530
Rendered shared/_flash.haml (2.0ms)
Rendered shared/_language_selector.html.haml (2.9ms)
Completed 200 OK in 159ms (Views: 30.1ms | ActiveRecord: 0.0ms)
这里的问题是 warden.authenticate!(auth_options) returns 没有。我检查了我的其他更简单的应用程序并验证了扫描数据库的行为,无论 email/password 是否正确。我如何让 Warden/Devise 实际执行 select 语句来检查数据库? 这是定义的路线 -
scope 'web' do
scope '/:locale' do
devise_for :users, controllers: {
passwords: 'users/passwords',
sessions: 'users/sessions',
registrations: 'users/registrations'
}
end
end
(如果有什么可以贴出来帮助大家的我会贴出来的)
看起来问题出在 /cable
操作上,它以某种方式阻止 current authentication
进程或操作完成。您可以通过在您的应用中评论 /cable
来验证这一点。