The combination of multiple user models (User, Admin, and Master) with devise_token_auth does not successfully set the Response Headers (uid, token, etc.) upon login with non "User" models (Admin and Master); however, User model works.
The cause looks to be the default serialization_scope (:current_user) in active_model_serializers/lib/action_controller/serialization.rb:18.
Is there a way to set the serialization_scope, or do I need to override the controllers?
Environment:
My current work around was to set the scope in an overridden controller like below. This feels brittle, but it works
class Overrides::Master::SessionsController < DeviseTokenAuth::SessionsController
protected
def render_create_success
render json: {
data: resource_data(resource_json: @resource.token_validation_response)
}, scope: :current_master
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With