On Aug 31, 2011, at 1:51 PM, Jim Harvey wrote:
> I'm basically trying to duplicate the functionality of Hobo's
> forgot_password as a "need_password" cycle for inactive users that
> have accounts set up by admins but have no passwords initially. I
> tried setting up a lifecycle like below but I'm having trouble because
> Hobo expects to have a user_id to display the "need_password" page
> which I want to be just like the "forgot_password" with a form to
> enter the email and THEN look up the user. If this makes sense and
> anyone has any advice on how I should proceed with this the hobo way,
> I'd be grateful...
I've got a couple apps that borrow the forgot-password stuff; notably, they use
the page to also allow pending users to request a new activation email. Sounds
weird, but it came about when I noticed that users whose activations were held
up (f-ing HOTMAIL, argh) would always wind up on the forgot password page...
Here's an example lifecycle:
lifecycle do
state :passive, :default => true
state :pending
state :active
# users set password on activation
transition :activate, { :pending => :active }, :available_to =>
:key_holder, :params => [:password, :password_confirmation]
transition :request_password_reset, { :active => :active }, :new_key =>
true do
UserMailer.deliver_forgot_password(self, lifecycle.key)
end
transition :request_password_reset, { :pending => :pending } do
UserMailer.deliver_activation(self, lifecycle.key)
end
transition :request_password_reset, { :passive => :pending }, :new_key =>
true do
UserMailer.deliver_activation(self, lifecycle.key)
end
transition :reset_password, { :active => :active }, :available_to =>
:key_holder,
:params => [ :password, :password_confirmation ]
end
Note that the 'request_password_reset' transition is where all the magic
happens - in the app this is paraphrased from, users were mass-imported from
the client's legacy Access DB as 'passive'. When they were ready to access
their accounts, they were instructed to use the "forgot password" function to
start the activation process.
One thing to notice - :new_key is NOT used on the pending -> pending
transition; this may be a bug depending on your application. In my case, it was
important to avoid the slow-delivery problem where a user activates their
account, doesn't get a mail right away, requests another one and THEN the first
activation gets delivered (but doesn't work, since the key has changed).
Hope this helps!
--Matt Jones
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.