Commit 60ee498b authored by jplang's avatar jplang

Fixed: User#identity_url raises an error when invalid url is supplied (#2742).

git-svn-id: https://svn.redmine.org/redmine/trunk@2476 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent d4b3d1d2
......@@ -81,10 +81,14 @@ class User < ActiveRecord::Base
end
def identity_url=(url)
begin
self.write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
rescue InvalidOpenId
# Invlaid url, don't save
if url.blank?
write_attribute(:identity_url, '')
else
begin
write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url))
rescue OpenIdAuthentication::InvalidOpenId
# Invlaid url, don't save
end
end
self.read_attribute(:identity_url)
end
......
......@@ -204,6 +204,17 @@ class UserTest < Test::Unit::TestCase
u = User.new( :identity_url => 'example.com' )
assert_equal normalized_open_id_url, u.identity_url
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
puts "Skipping openid tests."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment