Permalink
Browse files

Merge github.com:treamous/xweb

  • Loading branch information...
treamous committed Apr 28, 2011
2 parents efc6c6d + bcad029 commit 8eebe52ef3be696c014f5a48c13a750994987bd3
Showing with 5 additions and 2 deletions.
  1. +5 −2 xweb/petitionmkr/app/models/user.rb
@@ -7,6 +7,7 @@ class User < ActiveRecord::Base
attr_accessor :password_confirmation
#attr_reader :username
+
EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
NAME_REGEX = /^[a-zA-Z]+$/
@@ -15,7 +16,7 @@ class User < ActiveRecord::Base
validates :last_name, :presence => true, :length => { :maximum => 50 }, :format => {:with => NAME_REGEX, :message => ' should have alphabets only.'}
validates :username, :presence => true, :length => { :within => 8..25 }, :uniqueness => true
validates :signature, :presence => true, :length => { :within => 8..25 }
- validates :state, :presence => true , :format => {:with => NAME_REGEX, :message => ' should have alphabets only.'}
+ validates :state, :presence => true , :length => { :maximum => 2 }, :format => {:with => NAME_REGEX, :message => ' should have alphabets only.'}
validates :age, :presence => true
validates_numericality_of :age, :integer_only => true, :within => 0..100
validates :interest, :presence => true , :format => {:with => NAME_REGEX, :message => ' should have alphabets only.'}
@@ -27,7 +28,6 @@ class User < ActiveRecord::Base
# only on create, so other attributes of this user can be changed
validates_length_of :password, :within => 8..25, :on => :create
-
before_save :create_hashed_password
after_save :clear_password
@@ -36,6 +36,8 @@ class User < ActiveRecord::Base
attr_protected :hashed_password, :salt
+
+
# Verify user...
def self.authenticate(username="", password="")
user = User.find_by_username(username)
@@ -45,6 +47,7 @@ def self.authenticate(username="", password="")
return false
end
end
+
# The same password string with the same hash method and salt
# should always generate the same hashed_password.

0 comments on commit 8eebe52

Please sign in to comment.