Class: ForestLiana::DeviseController

Inherits:
ApplicationController show all
Defined in:
app/controllers/forest_liana/devise_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user_from_jwt, #deactivate_count_response, #forest_user, #internal_server_error, papertrail?, #serialize_model, #serialize_models

Methods inherited from BaseController

#route_not_found

Instance Method Details

#change_passwordObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/forest_liana/devise_controller.rb', line 3

def change_password
  resource = SchemaUtils.find_model_from_collection_name(
    params['data']['attributes']['collection_name'])

  user = resource.find(params['data']['attributes']['ids'].first)
  user.password = params['data']['attributes']['values']['New password']
  user.save

  if user.valid?
    head :no_content
  else
    render status: 400, json: {
      error: user.errors.try(:messages).try(:[], :password)
    }
  end
end