I'm not sure exactly what you're asking for, but here's what we do, in
a set up similar to yours.  The big difference is that our users don't
select the password when signing up, they select it with their
activation email.  I can't remember why we did it that way.   Most
users are set up without password via automated scripts.

If an inactive user uses the reset password functionality, we
re-deliver their activation email rather than send the reset password
email.


    create :signup, :available_to => "Guest", :become => :inactive,
:new_key => true,
    :params => [:salutation, :first_name, :middle_name, :last_name,
:suffix, :email_address, :phone_number, :state_id]  do
      UserMailer.deliver_activation([self], :key => lifecycle.key,
:user => self)
    end

transition :activate, { :inactive => :active }, :params => [:password,
:password_confirmation], :available_to => :key_holder

    transition :request_password_reset, { :active => :active },
:new_key => true do
        UserMailer.deliver_forgot_password([self], :key =>
lifecycle.key, :user => self)
    end

    transition :resend_activation, { :inactive => :inactive },
:new_key => true do
      UserMailer.deliver_activation([self], :key => lifecycle.key,
:user => self)
    end

    transition :reset_password, { :active => :active }, :available_to
=> :key_holder, :params => [ :password, :password_confirmation ]


and then in users_controller.rb:

index_action :reset_password_request

do reset_password_request
      if user.lifecycle.state.name == :inactive
        user.lifecycle.resend_activation!(:nobody)
      else
        user.lifecycle.request_password_reset!(:nobody)
      end
end

  def do_reset_password
    hobo_do_reset_password do
      if valid?
        respond_to do |wants|
          wants.html { redirect_to(:controller => "front", :action =>
"password_has_been_reset") }
          wants.js { hobo_ajax_response }
        end
      end
    end
  end


and in reset_password_request.dryml:

<forgot-password-page>
  <content-header:>
     To reset your password enter your email address blah blah blah
  </content-header:>

  <form: replace>
    <form action="&do_reset_password_request_url"
class="forgot-password" method="POST">

      <labelled-item-list >
        <labelled-item>
          <item-label >Email Address</item-label>
          <item-value>
            <input type="text" name="email_address" id="email-address"
class="email-address"  />
          </item-value>
        </labelled-item>
      </labelled-item-list>
      <div class="actions">
        <submit label="Send" />
        <a href="#{root_path}">Cancel</a>
      </div>
    </form>
  </form:>
</forgot-password-page>

This would have been a lot easier if we hadn't renamed "forgot
password" to "reset password request".   If you don't need your URL's
to match your titles you would have much less to change.   There's
also other stuff we've changed for other reasons,  I've edited some of
it out, but may have edited too much or too little.   I hope I've helped.

Bryan



On Wed, Aug 31, 2011 at 1:51 PM, Jim Harvey <[email protected]> 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...
>
> transition :need_password, { :inactive => :inactive }, :available_to
> => "Guest", :new_key => true do
>      UserMailer.need_password(self, lifecycle.key).deliver
> end
>
> transition :set_password, { :inactive => :active }, :available_to
> => :key_holder,
>     :params => [ :password, :password_confirmation ]
>
> --
> 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.
>
>

-- 
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.

Reply via email to