Module: AppossLdapAdapter::Auth

Defined in:
lib/apposs_ldap_adapter/auth.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/apposs_ldap_adapter/auth.rb', line 17

def callback
  begin
    email = env['omniauth.auth']['info']['email']
    user = User.find_or_create_by_email email
    session[:user_id] = user.id
    redirect_to '/'
  rescue Exception => e
    Rails.logger.error e.backtrace.join("\n")
    render :text => 'sign in failed.'
  end
end

#current_userObject



13
14
15
# File 'lib/apposs_ldap_adapter/auth.rb', line 13

def current_user
  @user ||= User.find(session[:user_id]) if session[:user_id]
end

#sso_authObject



3
4
5
6
7
8
9
10
11
# File 'lib/apposs_ldap_adapter/auth.rb', line 3

def sso_auth
  return if current_user
  if Rails.env == 'cucumber' or ENV['NOLOGIN']=='yes'
    user = User.find_or_create_by_email params['login_as']
    session[:user_id] = user.id
  else
    redirect_to '/auth/ldap'
  end
end