Class: TechlahomaAuth::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- TechlahomaAuth::ApplicationController
- Defined in:
- app/controllers/techlahoma_auth/application_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
- #auth_redirect ⇒ Object
- #check_cookie ⇒ Object
- #cookie_valid? ⇒ Boolean
- #current_user ⇒ Object
- #login_required ⇒ Object
- #not_authorized ⇒ Object
- #signed_in? ⇒ Boolean
Instance Method Details
#auth_redirect ⇒ Object
30 31 32 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 30 def auth_redirect observable_redirect_to "/auth/techlahoma?origin=#{request.protocol}#{request.host_with_port}#{request.fullpath}" end |
#check_cookie ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 7 def if ! session[:user_id] = nil end end |
#cookie_valid? ⇒ Boolean
13 14 15 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 13 def [:techlahoma_auth].present? && session[:user_id].present? && [:techlahoma_auth].to_s == session[:user_id].to_s end |
#current_user ⇒ Object
34 35 36 37 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 34 def current_user return nil unless session[:user_id] @current_user ||= User.find_by_id(session[:user_id]) end |
#login_required ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 17 def login_required if !current_user end end |
#not_authorized ⇒ Object
23 24 25 26 27 28 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 23 def respond_to do |format| format.html{ auth_redirect } format.json{ head :unauthorized } end end |
#signed_in? ⇒ Boolean
39 40 41 |
# File 'app/controllers/techlahoma_auth/application_controller.rb', line 39 def signed_in? current_user.present? end |