Permalink
Browse files

when auto-creating records:

- display the actual errors to the user
- make sure to not set attempted_record if the record couldn't be saved, otherwise it will be forced-saved by a callback later on
  • Loading branch information...
1 parent 1134b75 commit da8dc2916e39a2b61261ebc0c84091b46e45f739 @mreinsch mreinsch committed Mar 19, 2010
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/authlogic_openid/session.rb
@@ -109,17 +109,17 @@ def validate_by_openid
if !attempted_record
if auto_register?
- self.attempted_record = klass.new
- attempted_record.openid_identifier = openid_identifier
- attempted_record.send(:map_openid_registration, registration)
-
- if ! attempted_record.save
- errors.add(:openid_identifier, "error auto-registering new openid account")
+ auto_reg_record = klass.new
+ auto_reg_record.openid_identifier = openid_identifier
+ auto_reg_record.send(:map_openid_registration, registration)
+
+ if !auto_reg_record.save
+ auto_reg_record.errors.each {|attr, msg| errors.add(attr, msg) }
+ else
+ self.attempted_record = auto_reg_record
end
- return
else
errors.add(:openid_identifier, "did not match any users in our database, have you set up your account to use OpenID?")
- return
end
end
end

0 comments on commit da8dc29

Please sign in to comment.