Class: Subscribem::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Subscribem::ApplicationController
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_account ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'app/controllers/subscribem/application_controller.rb', line 3
def current_account
if user_signed_in?
@current_account ||= begin
account_id = env["warden"].user(:scope => :account)
Subscibem::Account.find(account_id)
end
end
end
|
#current_user ⇒ Object
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!(account, user)
env["warden"].set_user(user, :scope => :user)
env["warden"].set_user(account, :scope => :account)
end
|
#user_signed_in? ⇒ Boolean
21
22
23
|
# File 'app/controllers/subscribem/application_controller.rb', line 21
def user_signed_in?
env["warden"].authenticated?(:user)
end
|