From 744de56738d308fc21167e746c1284668036ab14 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Mon, 4 Mar 2024 10:25:35 -0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20cropped=20banner=20ima?= =?UTF-8?q?ges=20being=20overwritten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When cropper.js intercepts an updated banner image file and crops it, the original filename gets changed to cropped.jpg which gets saved to disk. When another tenant crops their banner image, it also gets saved as cropped.jpg and overwrites the previous tenant's banner image. In this commit, we prepend the tenant name so it would look something like `shared-cropped.jpg` and `uindy-cropped.jpg` instead and avoids the files from being overwritten. Ref: - https://github.com/scientist-softserv/palni-palci/issues/948 - https://github.com/scientist-softserv/palni-palci/issues/746 --- app/views/hyrax/admin/appearances/_banner_image_form.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/hyrax/admin/appearances/_banner_image_form.html.erb b/app/views/hyrax/admin/appearances/_banner_image_form.html.erb index cc3067f91..867d2f540 100644 --- a/app/views/hyrax/admin/appearances/_banner_image_form.html.erb +++ b/app/views/hyrax/admin/appearances/_banner_image_form.html.erb @@ -75,7 +75,8 @@ document.querySelector('.banner-submit').addEventListener('click', function(e) { if (cropper) { cropper.getCroppedCanvas().toBlob(function(blob) { var formData = new FormData(document.querySelector('form')); - formData.append('admin_appearance[banner_image]', blob, 'cropped.jpg'); + var currentAccountName = "<%= current_account.name %>"; + formData.append('admin_appearance[banner_image]', blob, `${currentAccountName}-cropped.jpg`); $.ajax('/admin/appearance', { method: 'POST', From 29ba88c8766a7bb87549f0415cc40f9c05391ac1 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Mon, 4 Mar 2024 10:53:56 -0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A7=B9=20Rubocop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/omniauth_callbacks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 13235f900..6cb12bfb3 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -30,7 +30,7 @@ def callback # where we want a JS-based redirect to go. render 'complete', locals: { redirect_to_url: url || hyrax.dashboard_path } else - redirect_to root_path, flash: {error: 'Not able to log in user. #{@user.errors.full_messages}'} + redirect_to root_path, flash: { error: "Not able to log in user. #{@user.errors.full_messages}" } end end alias cas callback @@ -42,7 +42,7 @@ def passthru end def failure - redirect_to root_path, flash: {error: 'Authentication Failed. Something is wrong with the SSO configuration.'} + redirect_to root_path, flash: { error: 'Authentication Failed. Something is wrong with the SSO configuration.' } end end end