Class: ResetPasswordPortlet

Inherits:
Cms::Portlet
  • Object
show all
Defined in:
app/portlets/reset_password_portlet.rb

Instance Attribute Summary

Attributes inherited from Cms::Portlet

#connect_to_container, #connect_to_page_id, #controller

Instance Method Summary collapse

Methods inherited from Cms::Portlet

columns_for_index, connectable?, default_template, default_template_path, enable_template_editor, form, get_subclass, handler, has_edit_link?, #inline_options, #instance_name, #page_title, #portlet_type_name, render_inline, set_default_template_path, #store_errors_in_flash, #store_hash_in_flash, #store_params_in_flash, #type_name, types, #url_for_failure, #url_for_success

Instance Method Details

#renderObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/portlets/reset_password_portlet.rb', line 3

def render
  flash[:reset_password] = {}
  
  unless params[:token]
    flash[:reset_password][:error] = "No password token given"
    return
  end

  @user = Cms::User.find_by_reset_token(params[:token])

  unless @user
    flash[:reset_password][:notice] = "Invalid password token"    
    return
  end

  if request.post?
    @user.password = params[:password]
    @user.password_confirmation = params[:password_confirmation]
    
    if @user.save
      flash[:reset_password][:notice] = 'Password has been reset'
    end
  end
end