Class: Users::RegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Defined in:
app/controllers/users/registrations_controller.rb

Overview

Users registered via OAuth don't have a password So we need to override the update method so that they can update their account without providing a password

Instance Method Summary collapse

Instance Method Details

#createObject


6
7
8
# File 'app/controllers/users/registrations_controller.rb', line 6

def create
  super
end

#updateObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/users/registrations_controller.rb', line 10

def update
   = devise_parameter_sanitizer.sanitize(:account_update)

  # required for settings form to submit when password is left blank
  if [:password].blank?
    .delete("password")
    .delete("password_confirmation")
  end

  @user = User.find(current_user.id)
  if @user.update_attributes()
    set_flash_message :notice, :updated
    # Sign in the user bypassing validation in case his password changed
     @user, bypass: true
    redirect_to after_update_path_for(@user), notice: "Your profile has been updated."
  else
    render :edit
  end
end