Init version of device logging.
This commit is contained in:
parent
7d17849214
commit
0917cec855
1 changed files with 27 additions and 0 deletions
27
app/controllers/user_devices_controller.rb
Normal file
27
app/controllers/user_devices_controller.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
class UserDevicesController < ApplicationController
|
||||||
|
before_action :authentication_check
|
||||||
|
|
||||||
|
def index
|
||||||
|
devices = UserDevice.where(user_id: current_user.id).order('updated_at DESC')
|
||||||
|
devices_full = []
|
||||||
|
devices.each {|device|
|
||||||
|
attributes = device.attributes
|
||||||
|
if device.location_details['city']
|
||||||
|
attributes['country'] += ", #{device.location_details['city']}"
|
||||||
|
end
|
||||||
|
attributes.delete('created_at')
|
||||||
|
attributes.delete('device_details')
|
||||||
|
attributes.delete('location_details')
|
||||||
|
devices_full.push attributes
|
||||||
|
}
|
||||||
|
model_index_render_result(devices_full)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
UserDevice.where(user_id: current_user.id, id: params[:id]).destroy_all
|
||||||
|
render json: {}, status: :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue