Closed GabrielBortolote closed 4 years ago
Can't you override unauthorized_entity
? https://github.com/nsarno/knock#usage
I solved the problem this way:
class UserTokenController < Knock::AuthTokenController
rescue_from Knock.not_found_exception_class_name, with: :bad_request
def bad_request
render status: 404
end
def create
@user = User.find(auth_token.payload[:sub])
@auth_token = auth_token
end
def auth_params
login_param = Company.find(params[:company_id]).login_attribute
params.permit(login_param, :password)
end
end
If i send a Good Credencials post to my
UserTokenController < Knock::AuthTokenController
the default render object is a jbuilder wich the same name than the action in the controller. But if i send bad credencials, the only thing i can handle on the response is the status: 404. The action called by the routes for this path is not called too, just the methodauth_params
, unabling me to create a middle-way to handle the rendering object. But i need handle it. There is something blinding me ?