Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
lifecycle do
state :active
state :inactive, :default => true
create :signup, :available_to => "Guest",
:params => [:name, :email_address, :password, :password_confirmation],
:new_key => true, :become => :inactive do
UserMailer.send_later(:deliver_account_activation, self, lifecycle.key)
end
transition :activate_account, { :inactive => :active }, :available_to => :key_holder
# resend activation, issued by guest
transition :request_password_reset,
{ :inactive => :inactive },
:available_to => 'Guest',
:new_key => true do
UserMailer.send_later(:deliver_activation, self, lifecycle.key)
end
# deliver forgotten password
transition :request_password_reset,
{ :active => :active },
:available_to => 'Guest',
:new_key => true do
UserMailer.send_later(:deliver_forgot_password, self, lifecycle.key)
end
# do the actual reset
transition :reset_password,
{ :active => :active },
:available_to => :key_holder,
:params => [ :password, :password_confirmation ]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment