@@ -80,6 +80,15 class User < ActiveRecord::Base | |||||
80 | super |
|
80 | super | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
|
83 | def identity_url=(url) | |||
|
84 | begin | |||
|
85 | self.write_attribute(:identity_url, OpenIdAuthentication.normalize_identifier(url)) | |||
|
86 | rescue InvalidOpenId | |||
|
87 | # Invlaid url, don't save | |||
|
88 | end | |||
|
89 | self.read_attribute(:identity_url) | |||
|
90 | end | |||
|
91 | ||||
83 | # Returns the user that matches provided login and password, or nil |
|
92 | # Returns the user that matches provided login and password, or nil | |
84 | def self.try_to_login(login, password) |
|
93 | def self.try_to_login(login, password) | |
85 | # Make sure no one can sign in with an empty password |
|
94 | # Make sure no one can sign in with an empty password |
@@ -184,4 +184,23 class UserTest < Test::Unit::TestCase | |||||
184 | assert !u.password.blank? |
|
184 | assert !u.password.blank? | |
185 | assert !u.password_confirmation.blank? |
|
185 | assert !u.password_confirmation.blank? | |
186 | end |
|
186 | end | |
|
187 | ||||
|
188 | def test_setting_identity_url | |||
|
189 | normalized_open_id_url = 'http://example.com/' | |||
|
190 | u = User.new( :identity_url => 'http://example.com/' ) | |||
|
191 | assert_equal normalized_open_id_url, u.identity_url | |||
|
192 | end | |||
|
193 | ||||
|
194 | def test_setting_identity_url_without_trailing_slash | |||
|
195 | normalized_open_id_url = 'http://example.com/' | |||
|
196 | u = User.new( :identity_url => 'http://example.com' ) | |||
|
197 | assert_equal normalized_open_id_url, u.identity_url | |||
|
198 | end | |||
|
199 | ||||
|
200 | def test_setting_identity_url_without_protocol | |||
|
201 | normalized_open_id_url = 'http://example.com/' | |||
|
202 | u = User.new( :identity_url => 'example.com' ) | |||
|
203 | assert_equal normalized_open_id_url, u.identity_url | |||
|
204 | end | |||
|
205 | ||||
187 | end |
|
206 | end |
General Comments 0
You need to be logged in to leave comments.
Login now