Module: Aadhar::Authenticate

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
lib/aadhar/authenticate.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



5
6
7
# File 'lib/aadhar/authenticate.rb', line 5

def authenticate
	render :status => 401, :json => { :success => false, :info => "Unauthorized"} if !current_user.present?
end

#current_userObject



9
10
11
12
13
14
# File 'lib/aadhar/authenticate.rb', line 9

def current_user
    @current_user ||= begin
      authentication = AuthenticationToken.where(token: params[:auth_token]).first
      authentication.present? ? authentication.user : nil
    end
end