Class: DeviseTokenAuth::TokenValidationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/devise_token_auth/token_validations_controller.rb

Instance Method Summary collapse

Instance Method Details

#validate_token ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/devise_token_auth/token_validations_controller.rb', line 6

def validate_token
  # @resource will have been set by set_user_token concern
  if @resource
    render json: {
      success: true,
      data: @resource.as_json(except: [
        :tokens, :created_at, :updated_at
      ])
    }
  else
    render json: {
      success: false,
      errors: ["Invalid login credentials"]
    }, status: 401
  end
end