Sha256: 8aeb1f59296b72a3e709eef52305d41e6a8c89cc09d3795fbd2daa38fe1bb877
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
class <%= class_name %> < ActiveRecord::Base hobo_user_model # Don't put anything above this fields do username :string, :login => true, :name => true email_address :email_address administrator :boolean, :default => false timestamps end # This gives admin rights to the first sign-up. # Just remove it if you don't want that before_create { |user| user.administrator = true if count == 0 } # --- Signup lifecycle --- # lifecycle do initial_state :active create :anybody, :signup, :params => [:username, :email_address, :password, :password_confirmation], :become => :active, :if => proc {|_, u| u.guest?} transition :nobody, :request_password_reset, { :active => :active }, :new_key => true do <%= class_name %>Mailer.deliver_forgot_password(self, lifecycle.key) end transition :with_key, :reset_password, { :active => :active }, :update => [ :password, :password_confirmation ] end # --- Hobo Permissions --- # def creatable_by?(creator) creator.administrator? || !administrator end def updatable_by?(updater, new) updater.administrator? || (updater == self && only_changed_fields?(new, :password, :password_confirmation)) end def deletable_by?(deleter) deleter.administrator? end def viewable_by?(viewer, field) true end end
Version data entries
3 entries across 3 versions & 1 rubygems