[Logilogi-svn] SF.net SVN: logilogi:[1555] trunk
Status: Beta
Brought to you by:
wybow
|
From: <wy...@us...> - 2009-08-26 06:40:53
|
Revision: 1555
http://logilogi.svn.sourceforge.net/logilogi/?rev=1555&view=rev
Author: wybow
Date: 2009-08-26 06:40:46 +0000 (Wed, 26 Aug 2009)
Log Message:
-----------
Fixed openid bug reported by LiquidPub pplz
Modified Paths:
--------------
trunk/app/controllers/users_controller.rb
trunk/app/models/link.rb
trunk/app/models/user.rb
trunk/app/views/users/_method.html.erb
trunk/test/unit/user_test.rb
Modified: trunk/app/controllers/users_controller.rb
===================================================================
--- trunk/app/controllers/users_controller.rb 2009-08-25 20:04:42 UTC (rev 1554)
+++ trunk/app/controllers/users_controller.rb 2009-08-26 06:40:46 UTC (rev 1555)
@@ -58,6 +58,9 @@
else
flash.now[:error] = "Could not create your account"
shift_return_url
+ if !@user.openid_identifier.nil?
+ @selected = "openid"
+ end
render :action => :new
end
end
Modified: trunk/app/models/link.rb
===================================================================
--- trunk/app/models/link.rb 2009-08-25 20:04:42 UTC (rev 1554)
+++ trunk/app/models/link.rb 2009-08-26 06:40:46 UTC (rev 1555)
@@ -106,7 +106,7 @@
###### Validations
- # validate
+ validate :quick_validate
validates_presence_of :from_logi
validates_presence_of :requested_tags_string
validates_presence_of :received_tags_string
@@ -915,12 +915,6 @@
###### Validation-functions
- # Validates that it is to a different logi.
- #
- def validate
- self.quick_validate
- end
-
public
# Also called when adding links.
Modified: trunk/app/models/user.rb
===================================================================
--- trunk/app/models/user.rb 2009-08-25 20:04:42 UTC (rev 1554)
+++ trunk/app/models/user.rb 2009-08-26 06:40:46 UTC (rev 1555)
@@ -22,6 +22,8 @@
acts_as_authentic do |options|
options.login_field = :email
+ options.validate_email_field = false
+ options.validate_login_field = false
end
### Relationships
@@ -47,8 +49,8 @@
### Filters
- validate :normalize_openid_identifier
before_validation_on_create :set_home_page_tag # see HomePageModule
+ validate :name_not_reserved, :normalize_openid_identifier
before_create :assert_persistence_token
after_create :create_personal_user_group, :create_prefs_profiles, :create_home_page
before_destroy :reset_dependents
@@ -57,14 +59,14 @@
### Validations
# more in HomePageModule
+ validates_presence_of :name
validates_uniqueness_of :name
- validates_format_of :name, :with => /\s/,
- :message => "should be your full name"
validates_format_of :name, :with => /^[A-Z].*$/,
:message => "must start with a capital letter"
validates_format_of :name, :with => /^[\w\ _.-]+$/,
:message => "should only contain alphanumerical symbols, spaces," +
" underscores, dots and hyphens"
+ validates_presence_of :email
validates_uniqueness_of :email
validates_format_of :email, :with => /^[A-Za-z0-9_\.\-]+@[A-Za-z0-9\._-]+\.[A-Za-z]+$/,
:message => "is incorrect, please check for typo's"
@@ -189,18 +191,6 @@
protected
- # Makes sure the openid is normalized.
- #
- def normalize_openid_identifier
- if !self.openid_identifier.blank?
- begin
- self.openid_identifier = OpenIdAuthentication.normalize_identifier(self.openid_identifier)
- rescue OpenIdAuthentication::InvalidOpenId => e
- errors.add(:openid_identifier, e.message)
- end
- end
- end
-
# Makes sure the persistence token is not null.
#
def assert_persistence_token
@@ -289,4 +279,27 @@
end
return true
end
+
+
+ ###### Validation-functions
+
+ # Validates that it is to a different logi.
+ #
+ def name_not_reserved
+ if self.name =~ Const::Tag::RESERVED_WORDS_RE
+ errors.add(:name, 'can\'t be a reserved word')
+ end
+ end
+
+ # Makes sure the openid is normalized.
+ #
+ def normalize_openid_identifier
+ if !self.openid_identifier.blank?
+ begin
+ self.openid_identifier = OpenIdAuthentication.normalize_identifier(self.openid_identifier)
+ rescue OpenIdAuthentication::InvalidOpenId => e
+ errors.add(:openid_identifier, e.message)
+ end
+ end
+ end
end
Modified: trunk/app/views/users/_method.html.erb
===================================================================
--- trunk/app/views/users/_method.html.erb 2009-08-25 20:04:42 UTC (rev 1554)
+++ trunk/app/views/users/_method.html.erb 2009-08-26 06:40:46 UTC (rev 1555)
@@ -20,10 +20,11 @@
<% if selected == "normal" %>
<%= f.password_field :password %>
<%= f.password_field :password_confirmation %>
+ <%= f.submit _('Complete!') %>
<% else %>
<%= f.text_field :openid_identifier %>
+ <%= f.submit _('Continue') %>
<% end %>
- <%= f.submit _('Complete!') %>
<% end %>
<% end %>
Modified: trunk/test/unit/user_test.rb
===================================================================
--- trunk/test/unit/user_test.rb 2009-08-25 20:04:42 UTC (rev 1554)
+++ trunk/test/unit/user_test.rb 2009-08-26 06:40:46 UTC (rev 1555)
@@ -62,8 +62,8 @@
:name => 'covert cobra', :email => 'ra...@sn...')
# not starting with a capital leter
assert !u.save
- # no space, no full name
- u.name = "Cobra"
+ # reserved word
+ u.name = "Do"
assert !u.save
# ok
u.name = "Covert Cobra"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|