【发布时间】:2016-02-13 10:57:39
【问题描述】:
我有一个具有 base_controller.rb
的应用程序class Api::V1::BaseController < ApplicationController
before_filter :authenticate!
private
def authenticate!
session_token = request.env["HTTP_SESSIONTOKEN"]
@current_user = User.find_by(session_token: session_token) unless session_token.blank?
unless @current_user
return render_json(message: "ERROR: Invalid Session")
end
end
def render_json(data, status = :ok)
render json: data, status: status
end
end
当我调用继承基本控制器的 session_controller.rb 中的 sign_in 操作时,它给出“无效会话”。 我尝试使用邮递员,当我尝试在身份验证中使用“binding.pry”进行调试时!方法然后它将 session_token 设为 nil,为什么它给出 nil,因为我给出了用户的最新会话令牌。 我的应用程序运行良好,直到昨天。
【问题讨论】:
-
你能发布你的
session_controller.rb代码吗?
标签: ruby-on-rails debugging session authentication token