Open aaronskiba opened 5 months ago
def create
oauth = { provider: nil, uid: nil }
IdentifierScheme.for_users.each do |scheme|
oauth = session["devise.#{scheme.name.downcase}_data"] unless session["devise.#{scheme.name.downcase}_data"].nil?
end
blank_org = if Rails.configuration.x.application.restrict_orgs
sign_up_params[:org_id]['id'].blank?
else
sign_up_params[:org_id].blank?
end
if sign_up_params[:accept_terms].to_s == '0'
redirect_to after_sign_up_error_path_for(resource),
alert: _('You must accept the terms and conditions to register.')
elsif blank_org
redirect_to after_sign_up_error_path_for(resource),
alert: _('Please select an organisation from the list, or choose Other.')
else
existing_user = User.where_case_insensitive('email', sign_up_params[:email]).first
if existing_user.present?
if existing_user.invitation_token.present? && !existing_user.accept_terms?
# If the user is creating an account but they have an outstanding invitation, remember
# any plans that were shared with the invitee so we can attach them to the new User record
shared_plans = existing_user.roles
.select(&:active?)
.map { |role| { plan_id: role.plan_id, access: role.access } }
existing_user.destroy
else
redirect_to after_sign_up_error_path_for(resource),
alert: _('That email address is already registered.')
return
end
end
Because the migration changed the nil
accept_terms
values to true
, we can see how any affected users that also had an existing invitation_token
are now unable to create an account (direct_to after_sign_up_error_path_for(resource), alert: _('That email address is already registered.'
would be executed).
SELECT created_at, updated_at, invitation_created_at, invitation_sent_at
FROM users
WHERE invitation_token IS NOT null
AND accept_terms = true
ORDER BY invitation_created_at DESC
LIMIT 1;
The most recent occurence of this was on February 21, 2023; the same date as the release that performed the migration from MariaDB. https://github.com/portagenetwork/roadmap/releases/tag/3.1.0%2Bportage-3.1.0
This idea was applied to a single user in the production environment (i.e. A user where accept_terms = TRUE and invitation_token IS NOT NULL was updated in the db so that accept_terms = NULL). The fix was successful.
Please complete the following fields as applicable:
What version of the DMPRoadmap code are you running? (e.g. v2.2.0)
4.0.2+portage-4.0.1
Expected behaviour:
Actual behaviour:
Diagnosis
accept_terms
in the db for this new User isnull
:lib/tasks/rewrite_postgres.rake
:However:
Testing by changing the default value from nil to true:
Testing the app behaviour when the default_accept_terms value is changed to true:
testing_default_accept_terms@x.com
emailAffected Users
(
invitation_token
appears to be set to null after a user successfully creates an account.)