Module: Socialite::Controllers::Helpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/socialite/controllers/helpers.rb

Instance Method Summary collapse

Instance Method Details

#after_failure_pathObject



49
50
51
# File 'lib/socialite/controllers/helpers.rb', line 49

def after_failure_path
  main_app.root_path
end


41
42
43
# File 'lib/socialite/controllers/helpers.rb', line 41

def after_link_path
  main_app.root_path
end

#after_login_pathObject



53
54
55
# File 'lib/socialite/controllers/helpers.rb', line 53

def 
  main_app.root_path
end

#after_logout_pathObject



57
58
59
# File 'lib/socialite/controllers/helpers.rb', line 57

def after_logout_path
  main_app.root_path
end

#after_signup_pathObject



45
46
47
# File 'lib/socialite/controllers/helpers.rb', line 45

def 
  main_app.root_path
end

#current_userObject



10
11
12
13
14
15
16
# File 'lib/socialite/controllers/helpers.rb', line 10

def current_user
  @current_user ||= if session.has_key?(:user_id)
                      Socialite.user_class.find(session[:user_id])
                    end
rescue ActiveRecord::RecordNotFound
  session[:user_id] = nil
end

#current_user=(user) ⇒ Object



36
37
38
39
# File 'lib/socialite/controllers/helpers.rb', line 36

def current_user=(user)
  @current_user = user
  session[:user_id] = user.nil? ? user : user.id
end

#ensure_userObject



18
19
20
21
22
23
24
25
26
# File 'lib/socialite/controllers/helpers.rb', line 18

def ensure_user
  if defined?(super)
    super
  else
    unless user_signed_in?
      redirect_to , :alert => I18n.t('socialite.login_required')
    end
  end
end

#logout!Object



28
29
30
# File 'lib/socialite/controllers/helpers.rb', line 28

def logout!
  self.current_user = nil and session.destroy
end

#user_signed_in?Boolean



32
33
34
# File 'lib/socialite/controllers/helpers.rb', line 32

def user_signed_in?
  !!current_user
end