私は DeviseTokenAuth を使用している Rails 4 プロジェクトを持っています。すべて正常に動作しますが、特定のステータスを持つユーザーのアクセスを拒否したいと思います。だから基本的に
if user.status == :locked => Account :unauthorized
だからこれは私がこれまでやってきたことです
class SessionsController < DeviseTokenAuth::SessionsController
def new
super
end
def create
super
render json: { error: "Account is locked MOFO " }, status: :unauthorized if current_user.status.to_sym == :locked
end
end
しかし、私がそれを行うと、次のようになります:
AbstractController::DoubleRenderError - Render and/or redirect were called multiple times in this action. Please notethat you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".:
何か案が ?
ありがとう