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/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/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 diff --git a/config/routes.rb b/config/routes.rb index 7103e699..574a0f77 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,6 @@ Osem::Application.routes.draw do - - devise_for :users, :controllers => { :registrations => :registrations }, :path => 'accounts' - + devise_for :users, :controllers => { :registrations => :registrations,:passwords=>:passwords }, :path => 'accounts' + 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