Class: Comee::Core::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Comee::Core::UsersController
- Includes:
- Common
- Defined in:
- app/controllers/comee/core/users_controller.rb
Instance Method Summary collapse
Methods included from Common
#create, #index, #show, #update
Methods included from Pagination
#default_per_page, #order_by, #order_direction, #page_no, #paginate, #paginate_offset, #per_page
Methods inherited from ApplicationController
#application_code, #authenticate, #current_application, #current_user, #render_content, #render_error, #skip_bullet
Instance Method Details
#change_password ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/comee/core/users_controller.rb', line 6 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.[0]}, status: 422 end else render json: {success: false, error: "Old password doesn't match!"}, status: 422 end end |