From d6b3e16d557d5e5670dccefb0c96bc9094eeae19 Mon Sep 17 00:00:00 2001 From: SepsiLaszlo Date: Thu, 24 Jun 2021 07:42:15 -0700 Subject: [PATCH 01/10] enable sessionless login in development --- app/controllers/application_controller.rb | 6 +++++- app/views/application/_navbar.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d00361d3..ab6ac758 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -73,8 +73,12 @@ def current_semester end def current_user - return impersonate_user if ENV['NONAUTH'] + if Rails.env.development? && ENV['NONAUTH'] + authorization_header = request.env["HTTP_AUTHORIZATION"] + return User.find(authorization_header.split()[1]) if authorization_header + return impersonate_user + end @current_user ||= User.includes([{ memberships: [:group] }]).find(session[:user_id]) end helper_method :current_user diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index a6eff7df..d5fe6983 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -83,7 +83,7 @@ - <% if @notifications.any? %> + <% if @notifications&.any? %>