Sha256: 55702ed86386ffe0eb99981a67f8336e82a12cada15256ca6e6ec7becc917bd0

Contents?: true

Size: 879 Bytes

Versions: 6

Compression:

Stored size: 879 Bytes

Contents

module DeviseTokenAuth
  class TokenValidationsController < DeviseTokenAuth::ApplicationController
    skip_before_action :assert_is_devise_resource!, :only => [:validate_token]
    before_action :set_user_by_token, :only => [:validate_token]

    def validate_token
      # @resource will have been set by set_user_token concern
      if @resource
        yield @resource if block_given?
        render_validate_token_success
      else
        render_validate_token_error
      end
    end

    protected

    def render_validate_token_success
      render json: {
        success: true,
        data: resource_data(resource_json: @resource.token_validation_response)
      }
    end

    def render_validate_token_error
      render json: {
        success: false,
        errors: [I18n.t("devise_token_auth.token_validations.invalid")]
      }, status: 401
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
devise_token_auth-0.1.43.beta1 app/controllers/devise_token_auth/token_validations_controller.rb
devise_token_auth-0.1.42 app/controllers/devise_token_auth/token_validations_controller.rb
devise_token_auth-0.1.41 app/controllers/devise_token_auth/token_validations_controller.rb
devise_token_auth-0.1.40 app/controllers/devise_token_auth/token_validations_controller.rb
devise_token_auth-0.1.39 app/controllers/devise_token_auth/token_validations_controller.rb
devise_token_auth-0.1.38 app/controllers/devise_token_auth/token_validations_controller.rb