Story#113066359 - extract reserved domains regen password from domain to reserved domain

This commit is contained in:
Vladimir Krylov 2016-02-11 12:17:11 +02:00
parent 77da9ccd2b
commit 78ffe33dfa
2 changed files with 18 additions and 8 deletions

View file

@ -22,17 +22,30 @@ class ReservedDomain < ActiveRecord::Base
def any_of_domains names
where(name: names)
end
def new_password_for name
record = by_domain(name).first
return unless record
record.regenerate_password
record.save
end
end
def fill_empty_passwords
self.password = SecureRandom.hex if self.password.blank?
end
def name= val
super SimpleIDN.to_unicode(val)
end
def fill_empty_passwords
regenerate_password if self.password.blank?
end
def regenerate_password
self.password = SecureRandom.hex
end
def generate_data
return if Domain.where(name: name).any?