Sha256: 1895e1fe67ff19874d7c0035dab25407555895fb550611daedaef1f6be7fd843

Contents?: true

Size: 639 Bytes

Versions: 3

Compression:

Stored size: 639 Bytes

Contents

class UsersController < ApplicationController
  before_action :find_user

  def show
  end

  def update
    unless @user.authenticate(user_params[:current_password])
      @user.errors.add(:current_password, :wrong_password)
      return render :show
    end
    unless @user.update_attributes(user_params)
      return render :show
    end
    session[:succeed_password] = user_params[:password]
    redirect_to user_path
  end

  private

  def find_user
    @user = User.new(name: "admin") # user is only "admin"
  end

  def user_params
    params.require(:user).permit(:current_password, :password, :password_confirmation)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluentd-ui-0.1.2 app/controllers/users_controller.rb
fluentd-ui-0.1.1 app/controllers/users_controller.rb
fluentd-ui-0.1.0 app/controllers/users_controller.rb