Sha256: e4982ff02445e85c97de8b60cfbd8bfa01cd648d11d93d0bf1400b5ee9e08c7e

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

class ForgotPasswordPortlet < Cms::Portlet
  require 'digest/sha1'  

  enable_template_editor true

  def render
    logger.warn "Handling Class #{request.class}"
    logger.warn "Handling FORGOT as #{request.method}"
    logger.warn "Am I a POST? #{request.post?}"
    flash[:forgot_password] = {}

    return unless request.post?
    user = Cms::User.find_by_email(params[:email])

    logger.warn "Send email "

    unless user
      flash[:forgot_password][:error] = "We were unable to verify your account. Please make sure your email address is accurate."
      return
    end
    
    user.reset_token = generate_reset_token
    if user.save
      flash[:forgot_password][:notice] = "Your password has been sent to #{params[:email]}"
      Cms::ForgotPasswordMailer.deliver_reset_password(self.reset_password_url + '?token=' + user.reset_token, user.email)
    end
  end

  private
  def generate_reset_token
    Digest::SHA1.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join)
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
browsercms-3.5.7 app/portlets/forgot_password_portlet.rb
browsercms-3.5.6 app/portlets/forgot_password_portlet.rb
browsercms-3.5.5 app/portlets/forgot_password_portlet.rb
browsercms-3.5.4 app/portlets/forgot_password_portlet.rb
browsercms-3.5.3 app/portlets/forgot_password_portlet.rb
browsercms-3.5.2 app/portlets/forgot_password_portlet.rb
browsercms-3.5.1 app/portlets/forgot_password_portlet.rb
browsercms-3.5.0 app/portlets/forgot_password_portlet.rb
browsercms-3.5.0.rc3 app/portlets/forgot_password_portlet.rb
browsercms-3.5.0.rc2 app/portlets/forgot_password_portlet.rb
browsercms-3.5.0.rc1 app/portlets/forgot_password_portlet.rb
browsercms-3.4.2 app/portlets/forgot_password_portlet.rb
browsercms-3.4.2.rc1 app/portlets/forgot_password_portlet.rb
browsercms-3.4.1 app/portlets/forgot_password_portlet.rb
browsercms-3.4.0 app/portlets/forgot_password_portlet.rb
browsercms-3.4.0.rc2 app/portlets/forgot_password_portlet.rb
browsercms-3.4.0.rc1 app/portlets/forgot_password_portlet.rb