Created
February 26, 2010 21:05
-
-
Save kevinpfromnm/316159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lifecycle do | |
state :unverified, :default => true | |
state :verified,:active, :inactive, :banned | |
create :signup, :available_to => "Guest", | |
:params => [:name, :real_name, :birthday, :email_address, :password, :password_confirmation], | |
:become => :unverified, :new_key => true do | |
if self.birthday.to_time < 18.years.ago | |
UserMailer.deliver_email_verification(self, lifecycle.key) | |
else | |
UserMailer.deliver_email(self,"Account Request","We're sorry, but you must be over 18 to signup for an account.") | |
end | |
end | |
transition :verify_email_address, { :unverified => :verified }, :available_to => :key_holder do | |
UserMailer.deliver_email(self,"Email address verified","Your email address has been verified.") | |
end | |
transition :accept_terms, { :verified => :active }, :available_to => :user_account do | |
UserMailer.deliver_email(self,"Terms accepted","Now that you've accepted the terms of use, you can start submitting content.") | |
end | |
transition :deactivate, { [:verified,:active] => :inactive }, :available_to => :user_account do | |
UserMailer.deliver_email(self,"Account deactivated","At your request, your account has been deactivated.") | |
end | |
transition :activate, { :inactive => :verified }, :available_to => :user_account do | |
UserMailer.deliver_email(self,"Account reactivated","At your request, your account has been reactivated.") | |
end | |
transition :ban, { [:verified, :unverified, :active, :inactive] => :banned }, | |
:available_to => User.administrators do | |
UserMailer.deliver_email(self,"Account Banned","Due to violations, your account has been banned.") | |
end | |
transition :request_password_reset, { :active => :active }, :new_key => true do | |
UserMailer.deliver_forgot_password(self, lifecycle.key) | |
end | |
transition :reset_password, { :active => :active }, :available_to => :key_holder, | |
:params => [ :password, :password_confirmation ] | |
transition :change_email, { [:active, :inactive, :verified] => :unverified }, | |
:available_to => :user_account, | |
:params => [ :email_address ], :new_key => true do | |
UserMailer.deliver_email_verification(self, lifecycle.key) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment