1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2026-01-21 15:19:48 +00:00

admins don't need to verify domain ownership

هذا الالتزام موجود في:
Adam Cooke
2017-04-21 10:23:14 +01:00
الأصل b4744da8c1
التزام ec73bffce0
3 ملفات معدلة مع 16 إضافات و21 حذوفات

عرض الملف

@@ -27,9 +27,13 @@ class DomainsController < ApplicationController
scope = @server ? @server.domains : organization.domains scope = @server ? @server.domains : organization.domains
@domain = scope.build(params.require(:domain).permit(:name, :verification_method)) @domain = scope.build(params.require(:domain).permit(:name, :verification_method))
if current_user.admin?
@domain.verification_method = 'DNS'
@domain.verified_at = Time.now
end
if @domain.save if @domain.save
if @auto_verified if @domain.verified?
flash[:notice] = "Ownership of this domain does not need to be verified because it already has been verified in this organization."
redirect_to_with_json [:setup, organization, @server, @domain] redirect_to_with_json [:setup, organization, @server, @domain]
else else
redirect_to_with_json [:verify, organization, @server, @domain] redirect_to_with_json [:verify, organization, @server, @domain]

عرض الملف

@@ -50,13 +50,12 @@ class Domain < ApplicationRecord
VERIFICATION_METHODS = ['DNS', 'Email'] VERIFICATION_METHODS = ['DNS', 'Email']
validates :name, :presence => true, :format => {:with => /\A[a-z0-9\-\.]*\*?\z/}, :uniqueness => {:scope => [:owner_type, :owner_id], :message => "is already added"} validates :name, :presence => true, :format => {:with => /\A[a-z0-9\-\.]*\z/}, :uniqueness => {:scope => [:owner_type, :owner_id], :message => "is already added"}
validates :verification_method, :inclusion => {:in => VERIFICATION_METHODS} validates :verification_method, :inclusion => {:in => VERIFICATION_METHODS}
random_string :dkim_identifier_string, :type => :chars, :length => 6, :unique => true, :upper_letters_only => true random_string :dkim_identifier_string, :type => :chars, :length => 6, :unique => true, :upper_letters_only => true
before_create :generate_dkim_key before_create :generate_dkim_key
after_create :automatically_verify_domains_in_development
scope :verified, -> { where.not(:verified_at => nil) } scope :verified, -> { where.not(:verified_at => nil) }
@@ -72,15 +71,6 @@ class Domain < ApplicationRecord
end end
end end
def automatically_verify_domains_in_development
if Rails.env.development? && self.name && self.name =~ /\*\z/
self.name = self.name.gsub(/\*\z/, '')
self.verified_at = Time.now
self.verification_token = nil
self.save
end
end
def verified? def verified?
verified_at.present? verified_at.present?
end end

عرض الملف

@@ -22,14 +22,15 @@
.fieldSet__field .fieldSet__field
= f.label :name, :class => 'fieldSet__label' = f.label :name, :class => 'fieldSet__label'
.fieldSet__input= f.text_field :name, :autofocus => true, :class => 'input input--text' .fieldSet__input= f.text_field :name, :autofocus => true, :class => 'input input--text'
.fieldSet__field - unless current_user.admin?
= f.label :verification_method, :class => 'fieldSet__label' .fieldSet__field
.fieldSet__input = f.label :verification_method, :class => 'fieldSet__label'
= f.select :verification_method, Domain::VERIFICATION_METHODS, {}, :class => 'input input--select' .fieldSet__input
.fieldSet__text = f.select :verification_method, Domain::VERIFICATION_METHODS, {}, :class => 'input input--select'
Choose how you'd like to verify your ownership of this domain. If you choose <b>E-Mail</b> we can send you .fieldSet__text
an email with a code whcih you'll need to enter - you can choose from a set of pre-defined addresses for Choose how you'd like to verify your ownership of this domain. If you choose <b>E-Mail</b> we can send you
the domain. Using <b>DNS</b> you'll need to add a TXT record on this domain using your DNS provider. an email with a code whcih you'll need to enter - you can choose from a set of pre-defined addresses for
the domain. Using <b>DNS</b> you'll need to add a TXT record on this domain using your DNS provider.
.fieldSetSubmit .fieldSetSubmit
= f.submit :class => "button button--positive js-form-submit" = f.submit :class => "button button--positive js-form-submit"