Class: ErpTechSvcs::UserController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ErpTechSvcs::UserController
- Defined in:
- app/controllers/erp_tech_svcs/user_controller.rb
Instance Method Summary collapse
Instance Method Details
#activate ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'app/controllers/erp_tech_svcs/user_controller.rb', line 3 def activate login_url = params[:login_url].blank? ? ErpTechSvcs::Config.login_url : params[:login_url] if @user = User.load_from_activation_token(params[:activation_token]) @user.activate! redirect_to login_url, :notice => 'User was successfully activated.' else redirect_to login_url, :notice => "Invalid activation token." end end |
#reset_password ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/erp_tech_svcs/user_controller.rb', line 31 def reset_password begin login = params[:login].strip if user = (User.where('username = ? or email = ?', login, login)).first website = Website.find_by_host(request.host_with_port) if website user.add_instance_attribute(:website_id, website.id) end user.add_instance_attribute(:reset_password_url, (params[:reset_password_url] || '/erp_app/reset_password')) user.add_instance_attribute(:domain, params[:domain]) user.deliver_reset_password_instructions! = "Password has been reset. An email has been sent with further instructions to #{user.email}." success = true else = "Invalid user name or email address." success = false end render :json => {:success => success, :message => } rescue => ex Rails.logger.error ex. Rails.logger.error ex.backtrace.join("\n") ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier render :json => {:success => false, :message => 'Error sending email.'} end end |
#update_password ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/erp_tech_svcs/user_controller.rb', line 13 def update_password if user = User.authenticate(current_user.username, params[:old_password]) user.password_confirmation = params[:password_confirmation] if user.change_password!(params[:password]) success = true else #### validation failed #### = user.errors. success = false end else = "Invalid current password." success = false end request.xhr? ? (render :json => {:success => success, :message => }) : (render :text => ) end |