Skip to content

Commit

Permalink
bad updates
Browse files Browse the repository at this point in the history
  • Loading branch information
treamous committed Apr 12, 2011
1 parent 5aabf1b commit 23112d8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions xweb/petitionmkr/app/models/newuser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Newuser < ActiveRecord::Base

validates :first_name, :presence => true, :length => { :maximum => 25 }
validates :last_name, :presence => true, :length => { :maximum => 50 }
validates :username, :length => { :within => 8..25 }, :uniqueness => true
validates :signature, :length => { :within => 8..25 }, :uniqueness => true
validates :username, :presence => true, :length => { :within => 5..25 }, :uniqueness => true
validates :signature, :presence => true, :length => { :within => 8..25 }
validates :state, :presence => true
validates :age, :presence => true
validates :interest, :presence => true
Expand Down
9 changes: 7 additions & 2 deletions xweb/petitionmkr/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class User < ActiveRecord::Base

validates :first_name, :presence => true, :length => { :maximum => 25 }
validates :last_name, :presence => true, :length => { :maximum => 50 }
validates :username, :presence => true, :length => { :within => 8..25 }, :uniqueness => true
validates :signature, :length => { :within => 8..25 }, :uniqueness => true
validates :username, :presence => true, :length => { :within => 5..25 }, :uniqueness => true
validates :signature, :presence => true, :length => { :within => 8..25 }
validates :state, :presence => true
validates :age, :presence => true
validates :interest, :presence => true
Expand Down Expand Up @@ -53,6 +53,11 @@ def self.hash_with_salt(password="", salt="")
Digest::SHA1.hexdigest("Put #{salt} on the #{password}")
end

# Get default signature value
def self.def_sig()
"username#{Time.now}"
end

private

def create_hashed_password
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class ChangeSignUser < ActiveRecord::Migration
def self.up
change_column("users", "signature", :string, :default => :username)
#change_column("users", "signature", :string, :default => :username)
end

def self.down
change_column_default("users", "signature", nil)
#change_column_default("users", "signature", nil)
end
end
4 changes: 2 additions & 2 deletions xweb/petitionmkr/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110411072242) do
ActiveRecord::Schema.define(:version => 20110412062849) do

create_table "petitions", :force => true do |t|
t.string "title", :limit => 100, :null => false
Expand All @@ -37,7 +37,7 @@
t.string "username"
t.string "first_name", :limit => 40, :default => ""
t.string "last_name", :limit => 40, :default => ""
t.string "signature", :default => "username"
t.string "signature"
end

add_index "users", ["signature"], :name => "index_users_on_signature"
Expand Down
2 changes: 1 addition & 1 deletion xweb/petitionmkr/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# Mayor.create(:name => 'Daley', :city => cities.first)

User.create(:state => "MI",:age => "98", :interest => "None", :affiliation => "None", :password => "admin123", :username => "admin123", :signature => "admin123", :salt => User.make_salt("admin123"), :hashed_password => User.hash_with_salt("admin123", User.make_salt("admin123")), :email => "admin123@example.com", :first_name => "admin123", :last_name => "NoName")
User.create(:state => "AZ",:age => "1", :interest => "None", :affiliation => "None", :password => "mjca1234", :username => "mjca1234", :salt => User.make_salt("mjca1234"), :hashed_password => User.hash_with_salt("mjca1234", User.make_salt("mjca1234")), :email => "mjca1234@example.com", :first_name => "mjca1234", :last_name => "NoName")
User.create(:state => "AZ",:age => "1", :interest => "None", :affiliation => "None", :password => "mjca1234", :username => "mjca1234", :signature => "mjca1234", :salt => User.make_salt("mjca1234"), :hashed_password => User.hash_with_salt("mjca1234", User.make_salt("mjca1234")), :email => "mjca1234@example.com", :first_name => "mjca1234", :last_name => "NoName")

0 comments on commit 23112d8

Please sign in to comment.