Last active
March 3, 2021 12:49
-
-
Save emilsoman/5604254 to your computer and use it in GitHub Desktop.
Custom failure app to render a custom json on auth failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomAuthFailure < Devise::FailureApp | |
def respond | |
self.status = 401 | |
self.content_type = 'json' | |
self.response_body = {"errors" => ["Invalid login credentials"]}.to_json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're getting the PG exception probably because you're missing the validations on the User model.