Fill empty reserved domain passwords on save

This commit is contained in:
Martin Lensment 2015-09-23 19:19:32 +03:00 committed by Rene Vahtel
parent 89d831bb0e
commit d9c2b992d2
4 changed files with 1058 additions and 91 deletions

View file

@ -3,7 +3,7 @@ class Admin::ReservedDomainsController < AdminController
def index
rd = ReservedDomain.first_or_initialize
@reserved_domains = rd.names.to_yaml
@reserved_domains = rd.names.to_yaml.gsub("---\n", '')
end
def create

View file

@ -1,5 +1,10 @@
class ReservedDomain < ActiveRecord::Base
include Versions # version/reserved_domain_version.rb
before_save :fill_empty_passwords
def fill_empty_passwords
names.each { |k, v| names[k] = SecureRandom.hex if v.blank? }
end
class << self
def pw_for(domain_name)