Skip to content

Commit

Permalink
Security code works now, moved to a constant in environment.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
tumes committed Apr 14, 2011
1 parent d443d10 commit 9ca1a6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/models/user.rb
@@ -1,20 +1,17 @@
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :trackable, :validatable

attr_accessible :email, :name, :password, :password_confirmation, :terms_of_service
attr_accessible :email, :name, :password, :password_confirmation, :terms_of_service, :security_code
attr_accessor :security_code

validates_acceptance_of :terms_of_service, :accept => true
validate :correct_security_code, :on => :create

protected

# Security code constant lives in environment.rb
def correct_security_code
errors.add(:security_code, "Security code not valid") if security_code != "1234"
errors.add(:security_code, "Security code not valid") if security_code != SECURITY_CODE
end

# validates_each :security_code, :on => :create do |record, attr, value|
# record.errors.add attr, "Please enter correct security code" unless value && value == "1234"
# end

end
3 changes: 3 additions & 0 deletions config/environment.rb
Expand Up @@ -3,3 +3,6 @@

# Initialize the rails application
Chromalog::Application.initialize!

# Login security code, use to keep unwanted users out
SECURITY_CODE = "1234"

0 comments on commit 9ca1a6c

Please sign in to comment.