Commit 5cb35c7b authored by mgabdev's avatar mgabdev

Fixed issue with empty passwords for groups

• Fixed:
- issue with empty passwords for groups
parent a842bfb2
......@@ -56,6 +56,7 @@ class Group < ApplicationRecord
record.errors.add(:base, I18n.t('groups.errors.limit')) if Group.where(account_id: value).count >= PER_ACCOUNT_LIMIT
end
before_save :set_password
before_destroy :clean_feed_manager
after_create :add_owner_to_accounts
......@@ -72,6 +73,13 @@ class Group < ApplicationRecord
private
def set_password
if password.nil? || !password || password.gsub(/\s+/, "").length <= 1 || password == "null"
nil
else
password
end
end
def add_owner_to_accounts
group_accounts << GroupAccount.new(account: account, role: :admin, write_permissions: true)
end
......
......@@ -12,7 +12,7 @@ class REST::GroupSerializer < ActiveModel::Serializer
end
def has_password
return !!object.password
return !!object.password && object.password.gsub(/\s+/, "").length > 1 && object.password.to_s != "null"
end
def password
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment