Open saied2035 opened 1 year ago
I'm agree with you, why ? :)
I'm also working on a Rails API with devise and spent a long time trying to find documentation to override helpers like respond_with and respond_to_on_destroy. Feel like this needs more attention.
Hello Everyone,
Devise is one of my favorite gems. It has a lot of features, and it makes authentication easier for Rails applications. However, some code should be overridden to make it work with Rails API (JSON requests). My question is that why doesn't devise have the ability to handle API requests by default? Would it cause security issues?
I spent some time adding the ability to respond to API requests without changing any core logic. Could you take a look at some samples of code below?:
app/helpers/devise/sessions_helper.rb
app/controllers/devise/sessions_controller.rb
app/helpers/devise/registrations_helper.rb
app\controllers\devise\registrations_controller.rb
In
lib\devise\failure_app.rb
:I modified the
respond
function to have thejson_auth?
check:Implementation of
json_auth?
:Implementation of
unauthenticated_json
:I would like to discuss if it would be possible to add this code to the main branch to make the devise handle Rails applications/APIs the same way.