مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
chore: upgrade rails to 7.0 and other dependencies
هذا الالتزام موجود في:
@@ -8,13 +8,7 @@ module HasAuthentication
|
||||
has_secure_password
|
||||
|
||||
validates :password, length: { minimum: 8, allow_blank: true }
|
||||
|
||||
when_attribute :password_digest, changes_to: :anything do
|
||||
before_save do
|
||||
self.password_reset_token = nil
|
||||
self.password_reset_token_valid_until = nil
|
||||
end
|
||||
end
|
||||
before_save :clear_password_reset_token_on_password_change
|
||||
end
|
||||
|
||||
class_methods do
|
||||
@@ -42,6 +36,15 @@ module HasAuthentication
|
||||
AppMailer.password_reset(self, return_to).deliver
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clear_password_reset_token_on_password_change
|
||||
return unless password_digest_changed?
|
||||
|
||||
self.password_reset_token = nil
|
||||
self.password_reset_token_valid_until = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# -*- SkipSchemaAnnotations
|
||||
|
||||
@@ -39,7 +39,7 @@ class Credential < ApplicationRecord
|
||||
return if type == "SMTP-IP"
|
||||
return if persisted?
|
||||
|
||||
self.key = SecureRandomString.new(24)
|
||||
self.key = SecureRandom.alphanumeric(24)
|
||||
end
|
||||
|
||||
def to_param
|
||||
|
||||
@@ -61,17 +61,7 @@ class Domain < ApplicationRecord
|
||||
|
||||
scope :verified, -> { where.not(verified_at: nil) }
|
||||
|
||||
when_attribute :verification_method, changes_to: :anything do
|
||||
before_save do
|
||||
if verification_method == "DNS"
|
||||
self.verification_token = Nifty::Utils::RandomString.generate(length: 32)
|
||||
elsif verification_method == "Email"
|
||||
self.verification_token = rand(999_999).to_s.ljust(6, "0")
|
||||
else
|
||||
self.verification_token = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
before_save :update_verification_token_on_method_change
|
||||
|
||||
def verified?
|
||||
verified_at.present?
|
||||
@@ -168,4 +158,18 @@ class Domain < ApplicationRecord
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_verification_token_on_method_change
|
||||
return unless verification_method_changed?
|
||||
|
||||
if verification_method == "DNS"
|
||||
self.verification_token = Nifty::Utils::RandomString.generate(length: 32)
|
||||
elsif verification_method == "Email"
|
||||
self.verification_token = rand(999_999).to_s.ljust(6, "0")
|
||||
else
|
||||
self.verification_token = nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -35,12 +35,7 @@ class Webhook < ApplicationRecord
|
||||
scope :enabled, -> { where(enabled: true) }
|
||||
|
||||
after_save :save_events
|
||||
|
||||
when_attribute :all_events, changes_to: true do
|
||||
after_save do
|
||||
webhook_events.destroy_all
|
||||
end
|
||||
end
|
||||
after_save :destroy_events_when_all_events_enabled
|
||||
|
||||
def events
|
||||
@events ||= webhook_events.map(&:event)
|
||||
@@ -50,13 +45,22 @@ class Webhook < ApplicationRecord
|
||||
@events = value.map(&:to_s).select(&:present?)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def save_events
|
||||
return unless @events
|
||||
|
||||
@events.each do |event|
|
||||
webhook_events.where(event: event).first_or_create!
|
||||
end
|
||||
|
||||
webhook_events.where.not(event: @events).destroy_all
|
||||
end
|
||||
|
||||
def destroy_events_when_all_events_enabled
|
||||
return unless all_events
|
||||
|
||||
webhook_events.destroy_all
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم