[英]Throw a 404 error on unsuccessful authentication: devise + rails custom auth strategy
I have a custom auth strategy (it is the default strategy), which has an authenticate! 我有一个自定义身份验证策略(这是默认策略),它有一个身份验证! function.
功能。
def authenticate!
if validation_success
success!(resource)
else
fail(:invalid_token)
end
end
I want to modify it so that in the 'else' part of the loop, I directly return a 404 from this code itself. 我想修改它,以便在循环的'else'部分,我直接从此代码本身返回404。
raise ActiveRecord::RecordNotFound
生产环境使用404自动处理未找到的记录和路由错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.