mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Updated email hash to Gravatar specifications
Gravatar email hashes have two requirements: * Whitespace must be trimmed * Email should be downcased
This commit is contained in:
@@ -176,7 +176,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.email_hash(email)
|
||||
Digest::MD5.hexdigest(email)
|
||||
Digest::MD5.hexdigest(email.strip.downcase)
|
||||
end
|
||||
|
||||
def email_hash
|
||||
|
||||
2068
db/structure.sql
2068
db/structure.sql
File diff suppressed because it is too large
Load Diff
@@ -291,6 +291,22 @@ describe User do
|
||||
it 'should have a sane email hash' do
|
||||
@user.email_hash.should =~ /^[0-9a-f]{32}$/
|
||||
end
|
||||
|
||||
it 'should use downcase email' do
|
||||
@user.email = "example@example.com"
|
||||
@user2 = Fabricate(:user)
|
||||
@user2.email = "ExAmPlE@eXaMpLe.com"
|
||||
|
||||
@user.email_hash.should == @user2.email_hash
|
||||
end
|
||||
|
||||
it 'should trim whitespace before hashing' do
|
||||
@user.email = "example@example.com"
|
||||
@user2 = Fabricate(:user)
|
||||
@user2.email = " example@example.com "
|
||||
|
||||
@user.email_hash.should == @user2.email_hash
|
||||
end
|
||||
end
|
||||
|
||||
describe 'name heuristics' do
|
||||
|
||||
Reference in New Issue
Block a user