Module: RailsJwtAuth::WardenHelper

Defined in:
app/helpers/rails_jwt_auth/warden_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/rails_jwt_auth/warden_helper.rb', line 19

def self.included(base)
  return unless Rails.env.test? && base.name == 'ApplicationController'

  base.send(:rescue_from, RailsJwtAuth::Spec::NotAuthorized) do
    render json: {}, status: 401
  end
end

Instance Method Details

#authenticate!Object



15
16
17
# File 'app/helpers/rails_jwt_auth/warden_helper.rb', line 15

def authenticate!
  warden.authenticate!
end

#current_userObject



7
8
9
# File 'app/helpers/rails_jwt_auth/warden_helper.rb', line 7

def current_user
  warden.user
end

#signed_in?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'app/helpers/rails_jwt_auth/warden_helper.rb', line 3

def signed_in?
  !current_user.nil?
end

#wardenObject



11
12
13
# File 'app/helpers/rails_jwt_auth/warden_helper.rb', line 11

def warden
  request.env['warden']
end