Commit 03a2995e15e69ad1ec73b1c0ecefaf3d2551b0da

Authored by tomykaira
1 parent 8b7e404b

Fix #1009 Replace all special characters in user's identity

app/roles/account.rb
1 module Account 1 module Account
2 def identifier 2 def identifier
3 - email.gsub /[@.]/, "_" 3 + email.gsub /[^[:alnum:]]/, "_"
4 end 4 end
5 5
6 def is_admin? 6 def is_admin?
spec/models/user_spec.rb
@@ -22,6 +22,11 @@ describe User do @@ -22,6 +22,11 @@ describe User do
22 user.identifier.should == "test_mail_com" 22 user.identifier.should == "test_mail_com"
23 end 23 end
24 24
  25 + it "should return identifier without + sign" do
  26 + user = User.new(:email => "test+foo@mail.com")
  27 + user.identifier.should == "test_foo_mail_com"
  28 + end
  29 +
25 it "should execute callback when force_random_password specified" do 30 it "should execute callback when force_random_password specified" do
26 user = User.new(:email => "test@mail.com", :force_random_password => true) 31 user = User.new(:email => "test@mail.com", :force_random_password => true)
27 user.should_receive(:generate_password) 32 user.should_receive(:generate_password)