Module: Clearance::Authentication

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) authenticate(params)



17
18
19
20
21
# File 'lib/clearance/authentication.rb', line 17

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

- (Object) current_user



23
24
25
# File 'lib/clearance/authentication.rb', line 23

def current_user
  clearance_session.current_user
end

- (Object) current_user=(user)



27
28
29
30
31
# File 'lib/clearance/authentication.rb', line 27

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

- (Object) handle_unverified_request



51
52
53
54
# File 'lib/clearance/authentication.rb', line 51

def handle_unverified_request
  super
  sign_out
end

- (Object) sign_in(user, &block)



33
34
35
# File 'lib/clearance/authentication.rb', line 33

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

- (Object) sign_out



37
38
39
# File 'lib/clearance/authentication.rb', line 37

def sign_out
  clearance_session.sign_out
end

- (Boolean) signed_in?

Returns:

  • (Boolean)


41
42
43
# File 'lib/clearance/authentication.rb', line 41

def signed_in?
  clearance_session.signed_in?
end

- (Boolean) signed_out?

Returns:

  • (Boolean)


45
46
47
# File 'lib/clearance/authentication.rb', line 45

def signed_out?
  !signed_in?
end