Fixed: User#identity_url raises an error when invalid url is supplied (#2742).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2476 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3183445aea
commit
d643d9a94c
|
@ -81,11 +81,15 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def identity_url=(url)
|
def identity_url=(url)
|
||||||
|
if url.blank?
|
||||||
|
write_attribute(:identity_url, '')
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
self.write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
|
write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
|
||||||
rescue InvalidOpenId
|
rescue OpenIdAuthentication::InvalidOpenId
|
||||||
# Invlaid url, don't save
|
# Invlaid url, don't save
|
||||||
end
|
end
|
||||||
|
end
|
||||||
self.read_attribute(:identity_url)
|
self.read_attribute(:identity_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,17 @@ class UserTest < Test::Unit::TestCase
|
||||||
assert_equal normalized_open_id_url, u.identity_url
|
assert_equal normalized_open_id_url, u.identity_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_setting_blank_identity_url
|
||||||
|
u = User.new( :identity_url => 'example.com' )
|
||||||
|
u.identity_url = ''
|
||||||
|
assert u.identity_url.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_setting_invalid_identity_url
|
||||||
|
u = User.new( :identity_url => 'this is not an openid url' )
|
||||||
|
assert u.identity_url.blank?
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
puts "Skipping openid tests."
|
puts "Skipping openid tests."
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue