Skip to content

Commit

Permalink
Fixes #1466, override passwords controller from Devise
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Dec 10, 2015
1 parent cc8385d commit 6647535
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def pundit_unverified_modules

def pundit_unverified_classes
[
'RegistrationsController', 'SessionsController', 'ConfirmationsController', 'ToolboxController',
'RegistrationsController', 'SessionsController', 'ConfirmationsController',
'PasswordsController', 'ToolboxController',
'BankDetailsController', 'ExportsController', 'WelcomeController',
'CategoriesController', 'Peek::ResultsController', 'StyleguidesController',
'RemoteValidationsController', 'DiscourseController'
Expand Down
17 changes: 17 additions & 0 deletions app/controllers/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2012-2015, Fairmondo eG. This file is
# licensed under the GNU Affero General Public License version 3 or later.
# See the COPYRIGHT file for details.

class PasswordsController < Devise::PasswordsController
def update
super

# TODO: Remove duplicate code in passwords and sessions controllers
if cart = Cart.find_by_id(cookies.signed[:cart])
cart.update_attribute :user_id, current_user.id unless cart.user_id
else # user probably doesn't have cart cookie set
@current_cart = Cart.current_for current_user
cookies.signed[:cart] = @current_cart.id if @current_cart
end
end
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

resources :contents

devise_for :user, controllers: { registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations' }
devise_for :user, controllers: { passwords: 'passwords', registrations: 'registrations',
sessions: 'sessions', confirmations: 'confirmations' }

namespace :toolbox do
get 'session_expired', as: 'session_expired', constraints: { format: 'json' } # JSON info about session expiration. Might be moved to a custom controller at some point.
Expand Down

0 comments on commit 6647535

Please sign in to comment.