Class: Auth::CustomerRegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Includes:
Controllers::MasqueradeGuarded
Defined in:
app/controllers/auth/customer_registrations_controller.rb

Overview

Constant Summary

Constants included from Controllers::MasqueradeGuarded

Controllers::MasqueradeGuarded::DEFAULT_BLOCK_MESSAGE

Instance Method Summary collapse

Methods included from Controllers::MasqueradeGuarded

block_while_masquerading, #masquerade_blocks?

Instance Method Details

#editObject



40
41
42
# File 'app/controllers/auth/customer_registrations_controller.rb', line 40

def edit
  @account = Account.find(.id)
end

#edit_emailObject



16
17
18
19
# File 'app/controllers/auth/customer_registrations_controller.rb', line 16

def edit_email
  @account = Account.find(.id)
  render :edit_email
end

#set_report_errors_forObject (protected)

This controller instance set the model to use for detecting errors in the application_controller#write_flash_to_cookie method.



73
74
75
# File 'app/controllers/auth/customer_registrations_controller.rb', line 73

def set_report_errors_for
  @report_errors_for = [resource]
end

#updateObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/auth/customer_registrations_controller.rb', line 44

def update
  @account = Account.find(.id)
  # puts "params.inspect: #{params.inspect}"
  pass = params[:account].delete(:current_password)
  if @account.encrypted_password.blank? or @account.valid_password?(pass)
    if params[:account][:password] and params[:account][:password] == params[:account][:password_confirmation]
      if @account.update(params[:account])
        @account.notify({ activity: 'update_password' })
        # Sign in the user by passing validation in case his password changed
         @account
        @account.restore_authentication_token! # clear out old auth tokens
        set_flash_message :notice, :updated
        redirect_to 
      else
        render :edit, status: :unprocessable_entity
      end
    else
      flash.now[:error] = 'Uh oh! Password does not match confirmation.'
      render :edit, status: :unprocessable_entity
    end
  else
    flash.now[:error] = 'Uh oh! Incorrect password. Please enter your current password to change your password.'
    render :edit, status: :unprocessable_entity
  end
end

#update_emailObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/auth/customer_registrations_controller.rb', line 21

def update_email
  @account = Account.find(.id)
  pass = params[:account].delete(:password)
  if (@account.encrypted_password.blank? && @account.authentications.present?) || @account.valid_password?(pass)
    old_email = @account.email
     = @account.
    if @account.update_without_password(params[:account])
      @account.notify({ activity: 'update_email', old_email: old_email, old_login:  })
      set_flash_message :notice, :updated
      redirect_to 
    else
      render :edit_email, status: :unprocessable_entity
    end
  else
    flash.now[:error] = 'Uh oh! Incorrect password. Please enter your current password to change your e-mail/login.'
    render :edit_email, status: :unprocessable_entity
  end
end