1
0
Fork 1
mirror of https://github.com/mastodon/mastodon.git synced 2024-12-29 03:53:52 +00:00
mastodon/app/helpers/email_helper.rb
Eugen Rochko b3ceb3dcc4
Add canonical e-mail blocks for suspended accounts ()
Prevent new accounts from being created using the same underlying
e-mail as a suspended account using extensions and period
permutations. Stores e-mails as a SHA256 hash
2021-04-17 03:14:25 +02:00

19 lines
398 B
Ruby

# frozen_string_literal: true
module EmailHelper
def self.included(base)
base.extend(self)
end
def email_to_canonical_email(str)
username, domain = str.downcase.split('@', 2)
username, = username.gsub('.', '').split('+', 2)
"#{username}@#{domain}"
end
def email_to_canonical_email_hash(str)
Digest::SHA2.new(256).hexdigest(email_to_canonical_email(str))
end
end