-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathuser_passwords_controller.rb
More file actions
55 lines (45 loc) · 1.51 KB
/
user_passwords_controller.rb
File metadata and controls
55 lines (45 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true
class Spree::UserPasswordsController < Devise::PasswordsController
helper 'spree/base', 'spree/store'
include Spree::Core::ControllerHelpers::Auth
include Spree::Core::ControllerHelpers::Common
include Spree::Core::ControllerHelpers::Order
include Spree::Core::ControllerHelpers::Store
include SolidusAuthDevise::DeprecatedRoutes
# Overridden due to bug in Devise.
# respond_with resource, location: new_session_path(resource_name)
# is generating bad url /session/new.user
#
# overridden to:
# respond_with resource, location: spree.login_path
#
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
set_flash_message(:notice, :send_instructions) if is_navigational_format?
if resource.errors.empty?
respond_with resource, location: spree.login_path
else
respond_with_navigational(resource) { render :new }
end
end
# Devise::PasswordsController allows for blank passwords.
# Silly Devise::PasswordsController!
# Fixes spree/spree#2190.
def update
if params[:spree_user][:password].blank?
self.resource = resource_class.new
resource.reset_password_token = params[:spree_user][:reset_password_token]
set_flash_message(:error, :cannot_be_blank)
render :edit
else
super
end
end
protected
def translation_scope
'devise.user_passwords'
end
def new_session_path(resource_name)
spree.send("new_#{resource_name}_session_path")
end
end