Fixed forgot password, no redirect loop know while resetting forgotten password
This commit is contained in:
parent
ad544a117f
commit
697fc08e18
3 changed files with 50 additions and 2 deletions
38
app/controllers/passwords_controller.rb
Normal file
38
app/controllers/passwords_controller.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
5
spec/views/passwords/update.html.erb_spec.rb
Normal file
5
spec/views/passwords/update.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "passwords/update.html.erb" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue