Sha256: da352c52d2ad86873010d0c7589ddbe1bb1f6ab695865e57ac5dbb71c8bb0340

Contents?: true

Size: 1020 Bytes

Versions: 59

Compression:

Stored size: 1020 Bytes

Contents

module Comee
  module Core
    class UsersController < ApplicationController
      include Common

      def change_password
        @user = current_user
        if @user.authenticate(change_password_params[:old_password])
          if @user.update(password: change_password_params[:new_password],
                          password_confirmation: change_password_params[:new_password_confirmation])
            render json: {success: true, data: serialize(@user)}
          else
            render json: {success: false, error: @user.errors.full_messages[0]}, status: 422
          end
        else
          render json: {success: false, error: "Old password doesn't match!"}, status: 422
        end
      end

      private

      def change_password_params
        params.require(:payload).permit(:old_password, :new_password, :new_password_confirmation)
      end

      def model_params
        params.require(:payload).permit(:name, :email, :active, :password, :password_confirmation)
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
comee_core-0.3.62 app/controllers/comee/core/users_controller.rb
comee_core-0.3.61 app/controllers/comee/core/users_controller.rb
comee_core-0.3.60 app/controllers/comee/core/users_controller.rb
comee_core-0.3.59 app/controllers/comee/core/users_controller.rb
comee_core-0.3.58 app/controllers/comee/core/users_controller.rb
comee_core-0.3.57 app/controllers/comee/core/users_controller.rb
comee_core-0.3.56 app/controllers/comee/core/users_controller.rb
comee_core-0.3.55 app/controllers/comee/core/users_controller.rb
comee_core-0.3.54 app/controllers/comee/core/users_controller.rb
comee_core-0.3.53 app/controllers/comee/core/users_controller.rb
comee_core-0.3.51 app/controllers/comee/core/users_controller.rb
comee_core-0.3.50 app/controllers/comee/core/users_controller.rb
comee_core-0.3.49 app/controllers/comee/core/users_controller.rb
comee_core-0.3.48 app/controllers/comee/core/users_controller.rb
comee_core-0.3.47 app/controllers/comee/core/users_controller.rb
comee_core-0.3.46 app/controllers/comee/core/users_controller.rb
comee_core-0.3.45 app/controllers/comee/core/users_controller.rb
comee_core-0.3.44 app/controllers/comee/core/users_controller.rb
comee_core-0.3.43 app/controllers/comee/core/users_controller.rb
comee_core-0.3.42 app/controllers/comee/core/users_controller.rb