Class: PasswordChangeController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/authkit/templates/app/controllers/password_change_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/authkit/templates/app/controllers/password_change_controller.rb', line 13

def create
  if email_user.change_password(params[:password], params[:password_confirmation])
    # Do not automatically log in the user
    respond_to do |format|
      format.json { head :no_content }
      format.html {
        flash.now[:notice] = "Password updated successfully"
        redirect_to()
      }
    end
  else
    respond_to do |format|
      format.json { render json: { status: 'error', errors: email_user.errors }.to_json, status: 422 }
      format.html { render :show }
    end
  end
end

#showObject



6
7
8
9
10
11
# File 'lib/generators/authkit/templates/app/controllers/password_change_controller.rb', line 6

def show
  respond_to do |format|
    format.json { head :no_content }
    format.html
  end
end