about summary refs log tree commit diff
path: root/app/controllers/api/v1/devices_controller.rb
blob: c565e972b65fa440c2358d039a7e278eca3caadf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class Api::V1::DevicesController < ApiController
  before_action -> { doorkeeper_authorize! :read }
  before_action :require_user!

  respond_to :json

  def register
    Device.where(account: current_account, registration_id: params[:registration_id]).first_or_create!(account: current_account, registration_id: params[:registration_id])
    render_empty
  end

  def unregister
    Device.where(account: current_account, registration_id: params[:registration_id]).delete_all
    render_empty
  end
end