Class: Subscribem::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/subscribem/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_user!Object



26
27
28
29
30
31
# File 'app/controllers/subscribem/application_controller.rb', line 26

def authenticate_user!
  unless user_signed_in?
    flash[:notice] = "Please sign in."
    redirect_to "/sign_in"
  end
end

#current_accountObject



3
4
5
6
7
8
9
10
# File 'app/controllers/subscribem/application_controller.rb', line 3

def 
  if user_signed_in?
    @current_account ||= begin
       = env["warden"].user(:scope => :account)
      Subscibem::Account.find()
    end
  end
end

#current_userObject



12
13
14
15
16
17
18
19
# File 'app/controllers/subscribem/application_controller.rb', line 12

def current_user
  if user_signed_in?
    @current_user ||= begin
      user_id = env["warden"].user(:scope => :user)
      Subscribem::User.find(user_id)
    end
  end
end

#force_authentication!(account, user) ⇒ Object



33
34
35
36
# File 'app/controllers/subscribem/application_controller.rb', line 33

def force_authentication!(, user)
  env["warden"].set_user(user, :scope => :user)
  env["warden"].set_user(, :scope => :account)
end

#user_signed_in?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/controllers/subscribem/application_controller.rb', line 21

def user_signed_in?
  env["warden"].authenticated?(:user)
end