public
Description: Gitorious aims to provide a great way of doing distributed opensource code collaboration.
Homepage: http://gitorious.org/projects/gitorious
Clone URL: git://github.com/dysinger/gitorious.git
Search Repo:
Fixed issue with not normalizing identity_url when you add one to an 
existing account

Added Patrick to AUTHORS, removed .gitmodules file.
Johan Sørensen (author)
Mon Jun 09 15:27:30 -0700 2008
commit  9ee9e09520a4dc9706061c933713d87b94fdf5e0
tree    bc2f48a8f2a86dcb4a78c66c598c714b576baae1
parent  48c4fc05c9733c2633b6d88f0ae6648866e5a705
...
22
23
24
 
25
26
...
22
23
24
25
26
27
0
@@ -22,4 +22,5 @@ A list of these people in order of appearance:
0
   * Dag Odenhall <dag.odenhall@gmail.com>
0
   * Will Fisher <will@gina.alaska.edu>
0
   * Jonas Fonseca <fonseca@diku.dk>
0
+ * Patrick Aljord <patcito@gmail.com>
0
   
0
\ No newline at end of file
...
26
27
28
 
29
30
31
 
32
33
34
...
49
50
51
 
 
 
 
 
 
 
 
 
 
52
53
54
...
139
140
141
 
 
 
 
 
 
 
142
...
26
27
28
29
30
31
 
32
33
34
35
...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
150
151
152
153
154
155
156
157
158
159
160
0
@@ -26,9 +26,10 @@ class User < ActiveRecord::Base
0
 
0
   before_save :encrypt_password
0
   before_create :make_activation_code
0
+ before_validation :lint_identity_url
0
 
0
   def self.find_by_login!(name)
0
- find_by_login(name) || raise(ActiveRecord::RecordNotFound )
0
+ find_by_login(name) || raise(ActiveRecord::RecordNotFound)
0
   end
0
 
0
   # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
0
@@ -49,6 +50,16 @@ class User < ActiveRecord::Base
0
     end.join
0
   end
0
   
0
+ def validate
0
+ if !not_openid?
0
+ begin
0
+ OpenIdAuthentication.normalize_url(self.identity_url)
0
+ rescue OpenIdAuthentication::InvalidOpenId => e
0
+ errors.add(:identity_url, "Invalid url")
0
+ end
0
+ end
0
+ end
0
+
0
   # Activates the user in the database.
0
   def activate
0
     @activated = true
0
@@ -139,4 +150,11 @@ class User < ActiveRecord::Base
0
     def make_activation_code
0
       self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
0
     end
0
+
0
+ def lint_identity_url
0
+ return if not_openid?
0
+ self.identity_url = OpenIdAuthentication.normalize_url(self.identity_url)
0
+ rescue OpenIdAuthentication::InvalidOpenId
0
+ # validate will catch it instead
0
+ end
0
 end
...
154
155
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
158
159
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
0
@@ -154,6 +154,23 @@ describe User do
0
     User.authenticate(u.email, password).should_not be_nil
0
   end
0
   
0
+ it "normalizes identity urls" do
0
+ u = users(:johan)
0
+ u.identity_url = "http://johan.someprovider.com"
0
+ u.valid?.should be_true
0
+ u.identity_url.should == "http://johan.someprovider.com/"
0
+
0
+ u.identity_url = "http://johan.someprovider.com/me"
0
+ u.valid?.should be_true
0
+ u.identity_url.should == "http://johan.someprovider.com/me"
0
+ end
0
+
0
+ it "catches invalid identity_url" do
0
+ u = users(:johan)
0
+ u.identity_url = "€&/()"
0
+ u.should have(1).errors_on(:identity_url)
0
+ end
0
+
0
   protected
0
     def create_user(options = {})
0
       u = User.new({

Comments

    No one has commented yet.