diff options
author | Matthew Lemon <y@yulqen.org> | 2024-12-15 15:10:05 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-12-15 15:10:14 +0000 |
commit | f1d04d1390ac0e755e6ac4778927bf06c86e9ba3 (patch) | |
tree | 54d7f70f574dd6bfa300e00dad7b717af3ad180e | |
parent | da69dec36f9ee1f09cf19fbaae4c138051847357 (diff) |
Refactor user session handling and UI enhancements.
Updated logout redirection with a success notice and improved UI feedback on the home page. Enhanced navbar logic to reflect user authentication state, modified page titles, and adjusted access permissions for various controllers. Fixed admin access control for PDF resources index action.
-rw-r--r-- | app/controllers/pages_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/pdfresources_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/sessions_controller.rb | 2 | ||||
-rw-r--r-- | app/views/layouts/_navbar.html.erb | 11 | ||||
-rw-r--r-- | app/views/pages/home.html.erb | 5 | ||||
-rw-r--r-- | app/views/pages/more_info.html.erb | 2 |
6 files changed, 16 insertions, 8 deletions
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 58c0ee7..309fb05 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,4 +1,6 @@ class PagesController < ApplicationController + allow_unauthenticated_access only: %i[ home about more_info faq contact terms ] + def home end diff --git a/app/controllers/pdfresources_controller.rb b/app/controllers/pdfresources_controller.rb index a710404..3ea6503 100644 --- a/app/controllers/pdfresources_controller.rb +++ b/app/controllers/pdfresources_controller.rb @@ -1,6 +1,6 @@ class PdfresourcesController < ApplicationController before_action :set_pdfresource, only: %i[ show edit update destroy ] - before_action :require_admin, only: %i[ new create update destroy ] + before_action :require_admin, only: %i[ index new create update destroy ] # GET /pdfresources or /pdfresources.json def index diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 9785c92..185dfeb 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -16,6 +16,6 @@ class SessionsController < ApplicationController def destroy terminate_session - redirect_to new_session_path + redirect_to root_path, notice: "Logged out successfully." end end diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index af7a0e4..952e291 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -15,16 +15,17 @@ <a href="#" class="block py-2 px-3 rounded">About</a> </li> <li> - <a href="#" class="block py-2 px-3 rounded">Services</a> - </li> - <li> - <a href="#" class="block py-2 px-3 rounded">Pricing</a> + <a href="#" class="block py-2 px-3 rounded">FAQ</a> </li> <li> <a href="#" class="block py-2 px-3 rounde">Contact</a> </li> <li> - <%= link_to "Log out", Current.session, class: "block py-2 px-3", data: { turbo_method: :delete }%> + <% if Current.user %> + <%= link_to "Log out", Current.session, class: "block py-2 px-3", data: { turbo_method: :delete } %> + <% else %> + <%= link_to "Log in", new_session_path, class: "block py-2 px-3" %> + <% end %> </li> </ul> </div> diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb index 48d6433..e3dba04 100644 --- a/app/views/pages/home.html.erb +++ b/app/views/pages/home.html.erb @@ -1,4 +1,9 @@ <div class="min-h-screen"> + <% if notice.present? %> + <div class="flex justify-center"> + <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p> + </div> + <% end %> <section class="bg-gradient-to-r from-blue-300 to-blue-800 text-white"> <div class="container mx-auto px-4 py-20"> <div class="max-w-3xl mx-auto text-center"> diff --git a/app/views/pages/more_info.html.erb b/app/views/pages/more_info.html.erb index cba5373..9665410 100644 --- a/app/views/pages/more_info.html.erb +++ b/app/views/pages/more_info.html.erb @@ -1,7 +1,7 @@ <div class="container mx-auto px-4 py-8 max-w-7xl"> <!-- Title with gradient similar to Featured Resources --> <h1 class="text-4xl md:text-5xl font-bold text-center mb-12 bg-gradient-to-r from-blue-500 to-green-500 bg-clip-text text-transparent relative"> - More Information + Benefits of registering now <!-- Underline effect --> <span class="absolute bottom-0 left-1/2 transform -translate-x-1/2 w-24 h-1 bg-gradient-to-r from-blue-500 to-green-500 -mb-4"></span> </h1> |