Sha256: 90bf53e7ad13fee481f2a9e0239f99b5df81e7d7eb524493d3ffa689373c59f6

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

class MerbAuthSliceMultisite::Passwords <  MerbAuthSliceMultisite::Application
  
  def send_password
    @login_param = Merb::Authentication::Strategies::Multisite::Base.login_param
    @site_id_param = Merb::Authentication::Strategies::Multisite::Base.site_id_param
    @user = Merb::Authentication.user_class.first(@login_param => params[@login_param], @site_id_param => params[@site_id_param])
      
    if @user
      from = MerbAuthSliceMultisite[:send_password_from_email]
      raise "No :send_password_from_email option set for Merb::Slices::config[:merb_auth_slice_multisite][:send_password_from_email]" unless from 
      @user.password = @user.password_confirmation = new_generated_password     
      send_mail(MerbAuthSliceMultisite::SendPasswordMailer, :send_password, { :subject => (MerbAuthSliceMultisite[:send_password_subject] || "Forgetful? :)"), :from => from, :to => @user.email }, { :user => @user })
      @user.save
      redirect "/", :message => {:notice => "Password sent. Check your email."}
    else
      redirect "/", :message => {:error => "User with #{@login_param} \"%s\" not found".t(params[@login_param].freeze)}
    end
  end
  
  private
  
    def new_generated_password
      chars = ("a".."z").to_a
      start_password = ""
      1.upto(6) { |i| start_password << chars[rand(chars.size-1)] }
      @password = start_password
    end
 
end # MerbAuthSliceMultisite::Passwords

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
scottmotte-merb_auth_slice_multisite-0.7.3 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.7.4 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.7.5 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.8.0 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.8.1 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.8.3 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.8.4 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.8.5 app/controllers/passwords.rb
scottmotte-merb_auth_slice_multisite-0.8.6 app/controllers/passwords.rb
merb_auth_slice_multisite-0.8.6 app/controllers/passwords.rb