diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6a19e3d0..94e7183f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,8 +2,4 @@ class ApplicationController < ActionController::Base include Authentication # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. allow_browser versions: :modern - - def check_admin! - redirect_to root_path unless Current.user.is_admin? - end end diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index 985bf255..d0cec6ef 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -12,6 +12,10 @@ def allow_unauthenticated_access(**options) end end + def redirect_contributors + redirect_to dashboard_path unless Current.user.is_admin? + end + private def authenticated? resume_session @@ -35,7 +39,7 @@ def request_authentication end def after_authentication_url - session.delete(:return_to_after_authenticating) || regions_url + session.delete(:return_to_after_authenticating) || dashboard_url end def start_new_session_for(user) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb new file mode 100644 index 00000000..e1192e4d --- /dev/null +++ b/app/controllers/dashboard_controller.rb @@ -0,0 +1,2 @@ +class DashboardController < ApplicationController +end diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index 4366eca3..bd9ae4d1 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -1,4 +1,5 @@ class LanguagesController < ApplicationController + before_action :redirect_contributors before_action :set_language, only: [ :edit, :update ] def index diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 0be0ee45..4aa3afc5 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -1,5 +1,6 @@ class ProvidersController < ApplicationController before_action :set_provider, only: %i[ show edit update destroy ] + before_action :redirect_contributors def index @providers = Provider.all diff --git a/app/controllers/regions_controller.rb b/app/controllers/regions_controller.rb index 1b6b548e..7ff1c692 100644 --- a/app/controllers/regions_controller.rb +++ b/app/controllers/regions_controller.rb @@ -1,4 +1,5 @@ class RegionsController < ApplicationController + before_action :redirect_contributors before_action :set_region, only: %i[ show edit update destroy ] # GET /regions diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index ac1331b1..ebe37ccc 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -1,6 +1,5 @@ class TopicsController < ApplicationController before_action :set_topic, only: [ :show, :edit, :update, :destroy, :archive ] - before_action :check_admin!, only: :destroy def index @topics = scope.includes(:language, :provider) @@ -32,6 +31,7 @@ def update end def destroy + redirect_to topics_path and return unless Current.user.is_admin? @topic.destroy redirect_to topics_path end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 16aed061..10f38317 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,4 +1,5 @@ class UsersController < ApplicationController + before_action :redirect_contributors before_action :set_user, only: %i[ edit update destroy ] def index diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb new file mode 100644 index 00000000..68b9281f --- /dev/null +++ b/app/views/dashboard/index.html.erb @@ -0,0 +1,27 @@ +<% content_for :title, "Dashboard" %> + +
+
+
+
+
+

Dashboard

+
+
+
+

+ Welcome to your dashboard! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut + labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut + aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu fugiat nulla + pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt + mollit anim id est + laborum. +

+
+
+
+
+
+
diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index f6a41de2..f7761865 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -4,7 +4,7 @@