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



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

def create
  if @user.change_password(params[:password], params[:password_confirmation])
    (@user)

    respond_to do |format|
      format.json { head :no_content }
      format.html {
        flash.now[:notice] = "Password updated successfully"
        redirect_to(root_path)
      }
    end
  else
    respond_to do |format|
      format.json { render json: { status: 'error', errors: @user.errors }.to_json, status: 422 }
      format.html { render :show }
    end
  end
end

#showObject



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

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