Class: Devise::Strategies::HttpHeaderAuthenticatable

Inherits:
Base
  • Object
show all
Includes:
DeviseRemote::HttpHeaderAuthenticatableBehavior
Defined in:
lib/devise/strategies/http_header_authenticatable.rb

Instance Method Summary collapse

Methods included from DeviseRemote::HttpHeaderAuthenticatableBehavior

#valid_user?

Instance Method Details

#authenticate!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/devise/strategies/http_header_authenticatable.rb', line 14

def authenticate!
  user = remote_user(request.headers)
  if user.present?
    u = User.find_by(login: user)
    if u.nil?
      u = User.create(login: user, email: user)
      u.populate_attributes if u.respond_to?(:populate_attributes)
    end
    success!(u)
  else
    fail!
  end
end

#valid?Boolean

Called if the user doesn’t already have a rails session cookie

Returns:

  • (Boolean)


10
11
12
# File 'lib/devise/strategies/http_header_authenticatable.rb', line 10

def valid?
  valid_user?(request.headers)
end