Module: Clearance::Authentication

Extended by:
ActiveSupport::Concern
Included in:
Controller
Defined in:
lib/clearance/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(params) ⇒ Object



19
20
21
22
23
# File 'lib/clearance/authentication.rb', line 19

def authenticate(params)
  Clearance.configuration.user_model.authenticate(
    params[:session][:email], params[:session][:password]
  )
end

#current_userObject



25
26
27
# File 'lib/clearance/authentication.rb', line 25

def current_user
  clearance_session.current_user
end

#current_user=(user) ⇒ Object



29
30
31
32
33
# File 'lib/clearance/authentication.rb', line 29

def current_user=(user)
  warn "#{Kernel.caller.first}: [DEPRECATION] " +
    'Assigning the current_user has been deprecated. Use the sign_in method instead.'
  clearance_session. user
end

#handle_unverified_requestObject



53
54
55
56
# File 'lib/clearance/authentication.rb', line 53

def handle_unverified_request
  super
  sign_out
end

#sign_in(user, &block) ⇒ Object



35
36
37
# File 'lib/clearance/authentication.rb', line 35

def (user, &block)
  clearance_session. user, &block
end

#sign_outObject



39
40
41
# File 'lib/clearance/authentication.rb', line 39

def sign_out
  clearance_session.sign_out
end

#signed_in?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/clearance/authentication.rb', line 43

def signed_in?
  clearance_session.signed_in?
end

#signed_out?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/clearance/authentication.rb', line 47

def signed_out?
  !signed_in?
end