Class: Auth::CustomerPasswordsController
- Inherits:
-
Devise::PasswordsController
- Object
- Devise::PasswordsController
- Auth::CustomerPasswordsController
show all
- Includes:
- Controllers::DeviseReturnable
- Defined in:
- app/controllers/auth/customer_passwords_controller.rb
Constant Summary
Controllers::DeviseReturnable::ALLOWED_REDIRECT_HOSTS
Instance Method Summary
collapse
#check_for_devise_return_path, #devise_return_path_from_omniauth_hash, #safe_referer
Instance Method Details
#after_resetting_password_path_for(resource) ⇒ Object
55
56
57
58
59
|
# File 'app/controllers/auth/customer_passwords_controller.rb', line 55
def after_resetting_password_path_for(resource)
return new_session_path(resource_name) unless sign_in_after_reset_password?
@devise_return_path.presence || my_account_path
end
|
#after_sending_reset_password_instructions_path_for(resource_name) ⇒ Object
61
62
63
64
65
66
67
|
# File 'app/controllers/auth/customer_passwords_controller.rb', line 61
def after_sending_reset_password_instructions_path_for(resource_name)
if @devise_return_path.present?
new_session_path(resource_name, devise_return_path: @devise_return_path)
else
new_session_path(resource_name)
end
end
|
#create {|resource| ... } ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/auth/customer_passwords_controller.rb', line 13
def create
login = params.dig(:account, :login)
@account = Account.where(login: login).first || Account.where(email: login).first rescue nil
self.resource = resource_class.send_reset_password_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
redirect_to after_sending_reset_password_instructions_path_for(resource_name)
else
render :new, status: :unprocessable_entity, formats: :html
end
end
|
#new ⇒ Object
8
9
10
11
|
# File 'app/controllers/auth/customer_passwords_controller.rb', line 8
def new
super
resource.login = params[:login].presence if resource.respond_to?(:login=)
end
|
#set_report_errors_for ⇒ Object
This controller instance set the model to use for detecting errors in the application_controller#write_flash_to_cookie method.
70
71
72
|
# File 'app/controllers/auth/customer_passwords_controller.rb', line 70
def set_report_errors_for
@report_errors_for = [resource]
end
|
#update {|resource| ... } ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/auth/customer_passwords_controller.rb', line 32
def update
self.resource = resource_class.reset_password_by_token(resource_params)
yield resource if block_given?
if resource.errors.empty?
resource.unlock_access! if unlockable?(resource)
if sign_in_after_reset_password?
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message!(:notice, flash_message)
resource.after_database_authentication
sign_in(resource_name, resource)
else
set_flash_message!(:notice, :updated_not_active)
end
redirect_to after_resetting_password_path_for(resource)
else
set_minimum_password_length
render :edit, status: :unprocessable_entity, formats: :html
end
end
|