Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update
- if params[:id].nil?
- render :action => 'new'
- return
- end
- if params[:password].blank?
- flash[:notice] = "Password field cannot be blank."
- render :action => 'edit', :id => params[:id]
- return
- end
- @user = User.find_by_password_reset_code(params[:id]) if params[:id]
- raise if @user.nil?
- return if @user unless params[:password]
- if(params[:password] == params[:password_confirmation])
- @user.password_confirmation = params[:password_confirmation]
- @user.password = params[:password]
- @user.reset_password
- flash[:notice] = @user.save ? "Password reset." : "Password not re-set."
- else
- flash[:notice] = "Password mismatch."
- render :action => 'edit', :id => params[:id]
- return
- end
- redirect_to login_path
- rescue
- logger.error "Invalid reset code entered"
- flash[:notice] = "Sorry - That is an invalid password reset \
- code.(Perhaps your email client inserted a carriage return?)"
- redirect_to new_user_path
- end
Add Comment
Please, Sign In to add comment