Module: AuthLh::Authentication::ClassMethods

Defined in:
lib/auth_lh/authentication.rb

Instance Method Summary collapse

Instance Method Details

#all_externalObject



20
21
22
# File 'lib/auth_lh/authentication.rb', line 20

def all_external
  AuthLh.get_users
end

#change_password_urlObject



64
65
66
# File 'lib/auth_lh/authentication.rb', line 64

def change_password_url
  AuthLh.change_password_url
end

#find_current_user(session_token, remote_ip) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/auth_lh/authentication.rb', line 28

def find_current_user(session_token, remote_ip)
  if (session_token.present? && (@session_token != session_token))
    response = AuthLh.get_current_user(session_token, remote_ip)

    if response.nil?
      @cached_logged_user = nil
      @session_token = nil
      @login_error = nil
    else
      @cached_logged_user = response.user
      @session_token = session_token
      @login_error = response.reason
    end
  end

  if @cached_logged_user
    user = find_or_create_by(login: @cached_logged_user.)
    user.auth_user = @cached_logged_user
    user
  else
    nil
  end
end

#find_external(login) ⇒ Object



24
25
26
# File 'lib/auth_lh/authentication.rb', line 24

def find_external()
  all_external.find { |x| x. == .to_s }
end

#login_urlObject



52
53
54
55
56
57
58
# File 'lib/auth_lh/authentication.rb', line 52

def 
  if @login_error
    "#{AuthLh.}&reason=#{@login_error}"
  else
    AuthLh.
  end
end

#logout_urlObject



60
61
62
# File 'lib/auth_lh/authentication.rb', line 60

def logout_url
  AuthLh.logout_url
end