From 697fc08e18778e803d86cec11790047d1a74085d Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 14 Mar 2014 01:55:47 +0530 Subject: [PATCH 1/3] Fixed forgot password, no redirect loop know while resetting forgotten password --- app/controllers/passwords_controller.rb | 38 ++++++++++++++++++++ config/routes.rb | 9 +++-- spec/views/passwords/update.html.erb_spec.rb | 5 +++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 app/controllers/passwords_controller.rb create mode 100644 spec/views/passwords/update.html.erb_spec.rb diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb new file mode 100644 index 00000000..4f0104ba --- /dev/null +++ b/app/controllers/passwords_controller.rb @@ -0,0 +1,38 @@ +class PasswordsController < Devise::PasswordsController + skip_before_filter :verify_user + def new + super + end + + def edit + super + + end + + def update + @user = User.find_by_reset_password_token(params[:user][:reset_password_token]) + logger.debug "#{@user.email}" + password_changed = false + if !params[:user][:password].nil? + if !params[:user][:password].empty? + password_changed = true + else + params[:user].delete :password + params[:user].delete :password_confirmation + end + end + + if password_changed + successfully_updated = @user.reset_password!(params[:user][:password],params[:user][:password_confirmation]) + else + redirect_to session[:return_to], :notice => "Blank Field Entered" and return + end + + if successfully_updated + redirect_to root_path, :notice => "Your password is changed" and return + else + redirect_to session[:return_to] and return + end + end + +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7103e699..e19942ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,12 @@ Osem::Application.routes.draw do - devise_for :users, :controllers => { :registrations => :registrations }, :path => 'accounts' - + devise_for :users, :controllers => { :registrations => :registrations,:passwords=>:passwords }, :path => 'accounts' + + # resources :passwords do + # get "passwords/new" => "passwords#new" + # get "/passwords/:id/edit" => "passwords#edit" + # end + namespace :admin do resources :users resources :people diff --git a/spec/views/passwords/update.html.erb_spec.rb b/spec/views/passwords/update.html.erb_spec.rb new file mode 100644 index 00000000..87943554 --- /dev/null +++ b/spec/views/passwords/update.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "passwords/update.html.erb" do + pending "add some examples to (or delete) #{__FILE__}" +end From 912478fde9cb763babde03c224cb132f0277726b Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Mon, 17 Mar 2014 21:13:03 +0530 Subject: [PATCH 2/3] Removed comments from routes --- config/routes.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index e19942ea..574a0f77 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,12 +1,6 @@ Osem::Application.routes.draw do - devise_for :users, :controllers => { :registrations => :registrations,:passwords=>:passwords }, :path => 'accounts' - # resources :passwords do - # get "passwords/new" => "passwords#new" - # get "/passwords/:id/edit" => "passwords#edit" - # end - namespace :admin do resources :users resources :people From d414cfab986cbfe63c64ea4a90e86a54b079412a Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Thu, 20 Mar 2014 10:06:09 +0530 Subject: [PATCH 3/3] Fixed incorrect variable in the supporter table and removed remote true --- app/controllers/admin/supporters_controller.rb | 4 ++-- app/views/admin/supporters/index.html.haml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/supporters_controller.rb b/app/controllers/admin/supporters_controller.rb index 8d887ad7..5ba4dec5 100644 --- a/app/controllers/admin/supporters_controller.rb +++ b/app/controllers/admin/supporters_controller.rb @@ -11,7 +11,7 @@ class Admin::SupportersController < ApplicationController def create params[:supporter_registration][:conference_id] = @conference.id supporter = SupporterRegistration.create!(params[:supporter_registration]) - flash[:notice] = "Supporter added" - render :json => {"status" => "ok"} + redirect_to(admin_conference_supporters_path(:conference_id => @conference.short_title), :notice => "Supporter added") + end end diff --git a/app/views/admin/supporters/index.html.haml b/app/views/admin/supporters/index.html.haml index 145696a3..4eabc399 100644 --- a/app/views/admin/supporters/index.html.haml +++ b/app/views/admin/supporters/index.html.haml @@ -1,5 +1,5 @@ #new-supporter-dialog - = semantic_form_for :supporter_registration, :remote => true, :html => {:id => "supporter-add-form"} do |f| + = semantic_form_for :supporter_registration, :html => {:id => "supporter-add-form"} do |f| = f.input :name, :label => "Supporter Name" = f.input :email, :label => "Supporter Email" = f.input :supporter_level_id, :as => :select, :collection => @conference.supporter_levels