【发布时间】:2013-07-18 00:04:14
【问题描述】:
我创建了一个 rails-api 应用程序并继续使用令牌身份验证来保护它。
我设置了一个before_filter,它正在调用一个使用authenticate_or_request_with_http_token 的方法。一切正常,但是当身份验证不正确时,我会收到一个 html 响应。
如何定义响应的格式?
before_filter :restrict_access
private
def restrict_access
authenticate_or_request_with_http_token do |token, options|
check_token token
end
end
def check_token(token)
Session.exists?(access_token: token)
end
【问题讨论】:
-
您能否展示您的一些代码以便人们实际提供帮助。
-
@GoGoGarrett 更新了我的问题。
标签: ruby-on-rails json rails-api