Class: Widgets::ResetPassword::Base
- Inherits:
-
ErpApp::Widgets::Base
- Object
- ErpApp::Widgets::Base
- Widgets::ResetPassword::Base
- Defined in:
- app/widgets/reset_password/base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #index ⇒ Object
-
#locate ⇒ Object
should not be modified modify at your own risk.
- #update_password ⇒ Object
Class Method Details
.base_layout ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/widgets/reset_password/base.rb', line 58 def base_layout begin file = File.join(File.dirname(__FILE__), "/views/layouts/base.html.erb") IO.read(file) rescue return nil end end |
.title ⇒ Object
50 51 52 |
# File 'app/widgets/reset_password/base.rb', line 50 def title "Reset Password" end |
.widget_name ⇒ Object
54 55 56 |
# File 'app/widgets/reset_password/base.rb', line 54 def File.basename(File.dirname(__FILE__)) end |
Instance Method Details
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/widgets/reset_password/base.rb', line 5 def index @website = Website.find_by_host(request.host_with_port) @reset_password_url = params[:reset_password_url] || '/reset-password' @domain = @website.configurations.first.get_item(ConfigurationItemType.find_by_internal_identifier('primary_host'))..first.value if params[:token].present? @token = params[:token].strip @user = User.load_from_reset_password_token(params[:token]) if @user.blank? render view: :invalid_reset_token else render view: :reset_password end else render end end |
#locate ⇒ Object
should not be modified modify at your own risk
45 46 47 |
# File 'app/widgets/reset_password/base.rb', line 45 def locate File.dirname(__FILE__) end |
#update_password ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/widgets/reset_password/base.rb', line 24 def update_password @login_url = params[:login_url].blank? ? '/login' : params[:login_url] @token = params[:token].present? ? params[:token].strip : nil @user = User.load_from_reset_password_token(@token) if @user.blank? render :update => {:id => "#{@uuid}_result", :view => :invalid_reset_token} else # the next line makes the password confirmation validation work @user.password_confirmation = params[:password_confirmation].strip # the next line clears the temporary token and updates the password if @user.change_password!(params[:password].strip) render :update => {:id => "#{@uuid}_result", :view => :reset_success} else render :update => {:id => "#{@uuid}_result", :view => :reset_password} end end end |