mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 09:48:06 +08:00
You can only reuse email tokens within 24 hours.
This commit is contained in:
@ -19,6 +19,10 @@ class EmailToken < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.valid_after
|
||||
1.week.ago
|
||||
end
|
||||
|
||||
def self.confirm_valid_after
|
||||
1.day.ago
|
||||
end
|
||||
|
||||
@ -38,7 +42,7 @@ class EmailToken < ActiveRecord::Base
|
||||
return unless token.present?
|
||||
return unless token.length/2 == EmailToken.token_length
|
||||
|
||||
email_token = EmailToken.where("token = ? and expired = FALSE and created_at >= ?", token, EmailToken.valid_after).includes(:user).first
|
||||
email_token = EmailToken.where("token = ? and expired = FALSE AND ((NOT confirmed AND created_at >= ?) OR (confirmed AND created_at >= ?))", token, EmailToken.valid_after, EmailToken.confirm_valid_after).includes(:user).first
|
||||
return if email_token.blank?
|
||||
|
||||
user = email_token.user
|
||||
|
Reference in New Issue
Block a user