diff --git a/app/controllers/stash_datacite/resources_controller.rb b/app/controllers/stash_datacite/resources_controller.rb
index 8759459f7..497cee350 100644
--- a/app/controllers/stash_datacite/resources_controller.rb
+++ b/app/controllers/stash_datacite/resources_controller.rb
@@ -38,8 +38,7 @@ def review
@resource.save!
@resource.reload
if @resource.identifier.payment_type.blank? || @resource.identifier.payment_type == 'unknown'
- session[:origin] = 'resource'
- session[:redirect_resource_id] = @resource.id
+ @target_page = stash_url_helpers.review_resource_path(@resource.id)
@aff_tenant = StashEngine::Tenant.find_by_ror_id(@resource.identifier&.submitter_affiliation&.ror_id).partner_list.first
end
end
@@ -73,7 +72,7 @@ def submission
session[:returnURL] = nil
redirect_to(return_url, notice: "Submitted updates for #{@resource.identifier}, title: #{@resource.title}", allow_other_host: true)
else
- redirect_to(stash_url_helpers.dashboard_path(doi: @resource.identifier.identifier), notice: resource_submitted_message(@resource))
+ redirect_to(stash_url_helpers.choose_dashboard_path(doi: @resource.identifier.identifier), notice: resource_submitted_message(@resource))
end
end
diff --git a/app/controllers/stash_engine/application_controller.rb b/app/controllers/stash_engine/application_controller.rb
index 58389ccd8..90a5198d7 100644
--- a/app/controllers/stash_engine/application_controller.rb
+++ b/app/controllers/stash_engine/application_controller.rb
@@ -29,14 +29,14 @@ def set_return_to_path_from_referrer
def user_not_authorized
flash[:alert] = 'You are not authorized to view this information.'
- redirect_back(fallback_location: '/stash/dashboard')
+ redirect_back(fallback_location: choose_dashboard_path)
end
def display_authorization_failure
Rails.logger.warn("Resource #{resource ? resource.id : 'nil'}: user ID is #{resource.user_id || 'nil'} but " \
"current user is #{current_user.id || 'nil'}")
flash[:alert] = 'You do not have permission to modify this dataset.'
- redirect_back(fallback_location: '/stash/dashboard')
+ redirect_back(fallback_location: choose_dashboard_path)
end
def redirect_url_for(original_url, host, port)
diff --git a/app/controllers/stash_engine/dashboard_controller.rb b/app/controllers/stash_engine/dashboard_controller.rb
index 20b26853c..35b26ab82 100644
--- a/app/controllers/stash_engine/dashboard_controller.rb
+++ b/app/controllers/stash_engine/dashboard_controller.rb
@@ -6,6 +6,12 @@ class DashboardController < ApplicationController
MAX_VALIDATION_TRIES = 5
+ def choose
+ return redirect_to admin_dashboard_path if current_user.min_admin?
+
+ redirect_to dashboard_path
+ end
+
def show
@doi = CGI.escape(params[:doi] || '')
end
diff --git a/app/controllers/stash_engine/metadata_entry_pages_controller.rb b/app/controllers/stash_engine/metadata_entry_pages_controller.rb
index 64ace1840..9c7ed7809 100644
--- a/app/controllers/stash_engine/metadata_entry_pages_controller.rb
+++ b/app/controllers/stash_engine/metadata_entry_pages_controller.rb
@@ -46,10 +46,10 @@ def edit_by_doi
if ownership_transfer_needed?
if current_user
- ca = CurationActivity.create(status: @resource.current_curation_status || 'in_progress',
- user_id: 0,
- resource_id: @resource.id,
- note: "Transferring ownership to #{current_user.name} (#{current_user.id}) using an edit code")
+ ca = CurationActivity.create(
+ status: @resource.current_curation_status || 'in_progress', user_id: 0, resource_id: @resource.id,
+ note: "Transferring ownership to #{current_user.name} (#{current_user.id}) using an edit code"
+ )
@resource.curation_activities << ca
@resource.user_id = current_user.id
@resource.current_editor_id = current_user.id
@@ -74,12 +74,11 @@ def edit_by_doi
redirect_to stash_url_helpers.choose_sso_path and return
end
end
-
if @resource&.current_resource_state&.resource_state == 'in_progress'
- redirect_to(stash_url_helpers.metadata_entry_pages_find_or_create_path(resource_id: resource.id))
- else
- new_version
+ redirect_to(stash_url_helpers.metadata_entry_pages_find_or_create_path(resource_id: resource.id)) and return
end
+
+ new_version
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -167,7 +166,7 @@ def require_can_duplicate
redirect_to(stash_url_helpers.metadata_entry_pages_find_or_create_path(resource_id: @identifier.in_progress_resource.id))
false
elsif @identifier.processing? || @identifier.error?
- redirect_to stash_url_helpers.dashboard_path,
+ redirect_to stash_url_helpers.choose_dashboard_path,
alert: 'You may not create a new version of the dataset until processing completes or any errors are resolved'
false
end
diff --git a/app/controllers/stash_engine/resources_controller.rb b/app/controllers/stash_engine/resources_controller.rb
index 32826162f..38c4bf998 100644
--- a/app/controllers/stash_engine/resources_controller.rb
+++ b/app/controllers/stash_engine/resources_controller.rb
@@ -104,7 +104,7 @@ def destroy
session[:returnURL] = nil
redirect_to(return_url, allow_other_host: true, notice: notice)
elsif current_user
- redirect_to return_to_path_or(dashboard_path), notice: notice
+ redirect_to return_to_path_or(choose_dashboard_path), notice: notice
else
redirect_to root_path, notice: notice
end
@@ -238,7 +238,7 @@ def resource_params
end
def require_in_progress
- redirect_to dashboard_path, alert: 'You may only edit the current version of the dataset' unless resource.current_state == 'in_progress'
+ redirect_to choose_dashboard_path, alert: 'You may only edit the current version of the dataset' unless resource.current_state == 'in_progress'
false
end
diff --git a/app/controllers/stash_engine/sessions_controller.rb b/app/controllers/stash_engine/sessions_controller.rb
index 65c974bf0..22e4c95df 100644
--- a/app/controllers/stash_engine/sessions_controller.rb
+++ b/app/controllers/stash_engine/sessions_controller.rb
@@ -95,7 +95,7 @@ def test_login
existing.update(first_name: params[:first_name], last_name: params[:last_name], email: params[:email],
tenant_id: params[:tenant_id])
session[:user_id] = existing.id
- redirect_to stash_url_helpers.dashboard_path, status: :found
+ redirect_to stash_url_helpers.choose_dashboard_path, status: :found
end
def choose_sso
@@ -117,6 +117,7 @@ def no_partner
# send the user to the tenant's SSO url
def sso
+ session[:target_page] = params[:target_page] if params[:target_page]
if StashEngine::Tenant.exists?(params[:tenant_id])
tenant = StashEngine::Tenant.find(params[:tenant_id])
case tenant&.authentication&.strategy
@@ -157,9 +158,7 @@ def orcid_preprocessor
@auth_hash = request.env['omniauth.auth']
@params = request.env['omniauth.params']
if @params['origin'] == 'feedback'
- session[:origin] = @params['origin']
- session[:contact_method] = @params['m']
- session[:link_location] = @params['l']
+ session[:target_page] = stash_url_helpers.feedback_path(m: @params['m'], l: @params['l'])
elsif @params['origin'] == 'metadata'
metadata_callback
elsif @params['invitation'] && @params['identifier_id']
@@ -179,7 +178,7 @@ def login_from_orcid
user = @users.first
session[:user_id] = user.id
# tenant = Tenant.find(user.tenant_id) # this was used to redirect to correct tenant, now not needed
- redirect_to stash_url_helpers.dashboard_path
+ redirect_to stash_url_helpers.choose_dashboard_path
end
# get orcid emails as returned by API
@@ -288,17 +287,12 @@ def validate_ip(tenant:)
end
def do_redirect
- case session[:origin]
- when 'feedback'
- redirect_to stash_url_helpers.feedback_path(m: session[:contact_method], l: session[:link_location])
- session[:origin] = session[:contact_method] = session[:link_location] = nil
- when 'account'
- redirect_to stash_url_helpers.my_account_path
- when 'resource'
- redirect_to stash_url_helpers.review_resource_path(session[:redirect_resource_id])
- else
- redirect_to stash_url_helpers.dashboard_path
+ target_page = session[:target_page]
+ if target_page.present?
+ session[:target_page] = nil
+ redirect_to target_page and return
end
+ redirect_to stash_url_helpers.choose_dashboard_path
end
def set_default_tenant
diff --git a/app/controllers/stash_engine/shared_security_controller.rb b/app/controllers/stash_engine/shared_security_controller.rb
index e486a14f5..81dde3924 100644
--- a/app/controllers/stash_engine/shared_security_controller.rb
+++ b/app/controllers/stash_engine/shared_security_controller.rb
@@ -24,15 +24,14 @@ def require_login
# to the login page. Now that they are logged in, we will redirect to the target_page,
# but first clear it from the session so we don't continually redirect to it.
session[:target_page] = nil
- redirect_to target_page
+ redirect_to target_page and return
end
return
end
return if valid_edit_code?
- flash[:alert] = 'You must be logged in.'
- session[:target_page] = request.fullpath
+ flash[:alert] = 'You must log in and select an institution (or none).'
redirect_to stash_url_helpers.choose_login_path
end
@@ -47,21 +46,21 @@ def require_not_obsolete
return if @resource&.current_resource_state&.resource_state == 'in_progress'
flash[:alert] = 'You may not edit a submitted version of your dataset by using the back button. Please open your dataset from the editing link'
- redirect_to stash_url_helpers.dashboard_path
+ redirect_to stash_url_helpers.choose_dashboard_path
end
def require_superuser
return if current_user && current_user.superuser?
flash[:alert] = 'You must be a superuser to view this information.'
- redirect_to stash_url_helpers.dashboard_path
+ redirect_to stash_url_helpers.choose_dashboard_path
end
def require_curator
return if current_user && current_user.min_curator?
flash[:alert] = 'You must be a curator to view this information.'
- redirect_to stash_url_helpers.dashboard_path
+ redirect_to stash_url_helpers.choose_dashboard_path
end
def ajax_require_curator
@@ -72,7 +71,7 @@ def require_min_app_admin
return if current_user && current_user.min_app_admin?
flash[:alert] = 'You must be a curator to view this information.'
- redirect_to stash_url_helpers.dashboard_path
+ redirect_to stash_url_helpers.choose_dashboard_path
end
def ajax_require_min_app_admin
@@ -83,7 +82,7 @@ def require_admin
return if current_user && current_user.min_admin?
flash[:alert] = 'You must be an administrator to view this information.'
- redirect_to stash_url_helpers.dashboard_path
+ redirect_to stash_url_helpers.choose_dashboard_path
end
# this requires a method called resource in the controller that returns the current resource (usually @resource)
diff --git a/app/controllers/stash_engine/user_account_controller.rb b/app/controllers/stash_engine/user_account_controller.rb
index b0daf7a5c..57d7b2dac 100644
--- a/app/controllers/stash_engine/user_account_controller.rb
+++ b/app/controllers/stash_engine/user_account_controller.rb
@@ -3,7 +3,7 @@ class UserAccountController < ApplicationController
before_action :require_user_login
def index
- session[:origin] = 'account'
+ @target_page = stash_url_helpers.my_account_path
end
def edit
diff --git a/app/views/stash_engine/admin_datasets/activity_log.html.erb b/app/views/stash_engine/admin_datasets/activity_log.html.erb
index 8ae08191a..bcaf33ed1 100644
--- a/app/views/stash_engine/admin_datasets/activity_log.html.erb
+++ b/app/views/stash_engine/admin_datasets/activity_log.html.erb
@@ -142,7 +142,6 @@
method: :post, :html => { onsubmit: "document.body.classList.add('prevent-clicks')" }) do -%>
<%= hidden_field_tag :resource_id, res&.id, id: "resource_id_#{res&.id}" %>
- <%= hidden_field_tag :return_url, '/stash/dashboard' %>
<% end %>
Forcibly editing a dataset will assign it to you, and begin an editing session.
Please only do this if you know the author is unable/unwilling to submit it.