diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cca1a436..f405c414 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -18,8 +18,13 @@ def logged_in? end def authenticate_user! - # TODO: redirect to login instead - head :unauthorized unless logged_in? + unless logged_in? + if request.format.json? + head :unauthorized + else + redirect_to root_path + end + end end private diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 50933fd1..04f8183d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,8 +2,8 @@ class UsersController < ApplicationController layout 'backoffice' + before_action :authenticate_user! before_action :set_user - before_action :verify_current_user # GET /users/1 # GET /users/1.json diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb index cd1e88ef..41cb15bc 100644 --- a/app/views/static_pages/home.html.erb +++ b/app/views/static_pages/home.html.erb @@ -21,7 +21,9 @@