mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) do not verify group change when no initial group
This commit is contained in:
parent
3bf08973fb
commit
36704be01d
@ -2,7 +2,8 @@
|
||||
|
||||
- Script to download translations from Crowdin
|
||||
- Fix a bug: admin and managers can't cancel or move event reservations
|
||||
- Fix a bug: phone numbers with hyphens and spaces prevent profile completion when the data is provided by a SSO
|
||||
- Fix a bug: phone numbers with hyphens and spaces prevent profile completion when the data is provided by an SSO
|
||||
- Fix a bug: unable to complete profile from SSO when the account validation is enabled
|
||||
|
||||
## v5.4.17 2022 September 06
|
||||
|
||||
|
@ -9,19 +9,19 @@ class Members::MembersService
|
||||
end
|
||||
|
||||
def update(params)
|
||||
if params[:group_id] && @member.group_id != params[:group_id].to_i && !@member.subscribed_plan.nil?
|
||||
if subscriber_group_change?(params)
|
||||
# here a group change is requested but unprocessable, handle the exception
|
||||
@member.errors.add(:group_id, I18n.t('members.unable_to_change_the_group_while_a_subscription_is_running'))
|
||||
return false
|
||||
end
|
||||
|
||||
if params[:group_id] && params[:group_id].to_i != Group.find_by(slug: 'admins').id && @member.admin?
|
||||
if admin_group_change?(params)
|
||||
# an admin cannot change his group
|
||||
@member.errors.add(:group_id, I18n.t('members.admins_cant_change_group'))
|
||||
return false
|
||||
end
|
||||
|
||||
group_changed = params[:group_id] && @member.group_id != params[:group_id].to_i
|
||||
group_changed = user_group_change?(params)
|
||||
ex_group = @member.group
|
||||
|
||||
user_validation_required = Setting.get('user_validation_required')
|
||||
@ -80,7 +80,7 @@ class Members::MembersService
|
||||
end
|
||||
|
||||
def validate(is_valid)
|
||||
is_updated = member.update(validated_at: is_valid ? Time.now : nil)
|
||||
is_updated = member.update(validated_at: is_valid ? DateTime.current : nil)
|
||||
if is_updated
|
||||
if is_valid
|
||||
NotificationCenter.call type: 'notify_user_is_validated',
|
||||
@ -133,4 +133,16 @@ class Members::MembersService
|
||||
params[:password]
|
||||
end
|
||||
end
|
||||
|
||||
def subscriber_group_change?(params)
|
||||
params[:group_id] && @member.group_id != params[:group_id].to_i && !@member.subscribed_plan.nil?
|
||||
end
|
||||
|
||||
def admin_group_change?(params)
|
||||
params[:group_id] && params[:group_id].to_i != Group.find_by(slug: 'admins').id && @member.admin?
|
||||
end
|
||||
|
||||
def user_group_change?(params)
|
||||
@member.group_id && params[:group_id] && @member.group_id != params[:group_id].to_i
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user