gpt4 book ai didi

ruby-on-rails - 设计:一个用户收到 302 和 401 错误,不知道为什么,更正日志中的凭据不多

转载 作者:行者123 更新时间:2023-12-04 16:49:23 25 4
gpt4 key购买 nike

我有一个通常工作正常的 Rails 应用程序,但是一个(我能找到的)用户导致了 302 错误,他们无法登录。日志看起来像这样:

Started GET "/d/sign_in" for 127.0.0.1 at 2014-12-15 05:38:14 +0000
Processing by Devise::SessionsController#new as */*
Rendered devise/sessions/new.html.erb within layouts/application (0.5ms)
Rendered layouts/_navigation.html.erb (2.3ms)
Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 10.1ms (Views: 7.2ms | ActiveRecord: 0.8ms)
Started GET "/d/sign_in" for 127.0.0.1 at 2014-12-15 05:38:14 +0000
Processing by Devise::SessionsController#new as */*
Rendered devise/sessions/new.html.erb within layouts/application (0.7ms)
Rendered layouts/_navigation.html.erb (2.2ms)
Rendered layouts/_messages.html.erb (0.2ms)
Completed 200 OK in 10.9ms (Views: 8.1ms | ActiveRecord: 0.7ms)
Started GET "/" for 58.111.229.203 at 2014-12-15 05:38:20 +0000
Processing by DocumentsController#index as HTML
Completed 401 Unauthorized in 0.5ms
Started POST "/d/sign_in" for 58.111.229.203 at 2014-12-15 05:38:28 +0000
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"cvyg6GWTtpd4M1klk0j6APbv4h36+a99yb9k646BRZA=", "user"=>{"email"=>"admin@blank.net", "password"=>"[FILTERED]"}, "commit"=>"Sign in"}
Redirected to http://appdomain.com/
Completed 302 Found in 310.2ms (ActiveRecord: 0.0ms)
Started GET "/d/sign_in" for 127.0.0.1 at 2014-12-15 05:38:29 +0000
Processing by Devise::SessionsController#new as */*
Rendered devise/sessions/new.html.erb within layouts/application (0.5ms)
Rendered layouts/_navigation.html.erb (2.7ms)
Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 10.1ms (Views: 7.4ms | ActiveRecord: 0.8ms)

现在,127.0.0.1 问题让我很担心,因为这是一个生产环境,但它可能只是一个服务 (Pingdom),确保应用程序仍在运行。尽管如此,这个用户无法登录,我也想不通。据我所知,没有其他用户受到影响,并且该用户拥有登录所需的一切。日志中没有详细的错误(例如缺少资源或类似错误),它只是在他们登录时挂起。任何帮助都会很棒。

更新

这是 DocumentsController(相关部分):

class DocumentsController < ApplicationController
include ApplicationHelper
include DocumentsHelper
include ServerHelper

load_and_authorize_resource

def index
@documents = current_user.documents.includes(:template).includes(:user)
.includes(:pdf_result).created.page(params[:page])
.per(10)
@categories = current_user.brand.templates.all.group_by(&:category)
@assets = AssetResources.new(current_user)
end

...

将此用户更改为管理员并不能解决问题。我想 ApplicationController 也是相关的,就是这样:

class ApplicationController < ActionController::Base
before_filter :authenticate_user!, :check_mode

protect_from_forgery

rescue_from CanCan::AccessDenied do |exception|
redirect_to documents_url, alert: exception.message
end

helper_method :current_user, :authorised_user

hide_action :current_user

def mode
@mode = Mode.first
end

def check_mode
flash.now[:alert] = mode.messages unless mode.all_online
end

private

def user_activity
current_user.try :touch
end

def authorised_user
@authorised_user ||= User.find(session[:user_id]) if session[:user_id]
end
end

更新 凭据正确,当输入该电子邮件地址和不正确的密码时,我会收到一条凭据错误消息。正确的凭据只是挂起。

最佳答案

检查

  1. 这个“admin@blank.net”用户是否存在于数据库中。
  2. 您提供的凭据是正确的。

因为登录失败时,devise内部会进行重定向,302是URL重定向的HTTP响应状态码。

在数据库中,确保该用户是否存在并且您提供了正确的凭据。

关于ruby-on-rails - 设计:一个用户收到 302 和 401 错误,不知道为什么,更正日志中的凭据不多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27478147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com