Class: CasAuthentication

Inherits:
Object
  • Object
show all
Defined in:
lib/components/cas_authentication.rb

Overview

Authenticate User and Create Session

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ CasAuthentication

Returns a new instance of CasAuthentication.



4
5
6
# File 'lib/components/cas_authentication.rb', line 4

def initialize(session)
  @session = session
end

Instance Method Details

#performObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/components/cas_authentication.rb', line 13

def perform
  return true if authenticated?
  return unless session['cas'].present?

  if new_user?
    authenticate! if create_user!
  elsif unauthenticated?
    authenticate!
    update_extra_attributes!
  end
end

#userObject



8
9
10
11
# File 'lib/components/cas_authentication.rb', line 8

def user
  return unless username.present?
  @user ||= User.find_or_initialize_by(username: username)
end