555132bbef
Devices now belong to Identity instead of User, allowing a single device registration to work across all accounts an identity has access to. - Move User::Devices to Identity::Devices - Update DevicesController to use Current.identity - Update NotificationPusher::Native to use user.identity.devices - Clean up tests to use @identity directly Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Fix reference to `user.devices`, left-over from the identity switch
31 lines
777 B
Ruby
31 lines
777 B
Ruby
class DevicesController < ApplicationController
|
|
before_action :set_device, only: :destroy
|
|
|
|
def index
|
|
@devices = Current.identity.devices.order(created_at: :desc)
|
|
end
|
|
|
|
def create
|
|
ApplicationPushDevice.register(owner: Current.identity, **device_params)
|
|
head :created
|
|
end
|
|
|
|
def destroy
|
|
@device.destroy
|
|
respond_to do |format|
|
|
format.html { redirect_to devices_path, notice: "Device removed" }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
private
|
|
def set_device
|
|
@device = Current.identity.devices.find_by(token: params[:id]) || Current.identity.devices.find(params[:id])
|
|
end
|
|
|
|
def device_params
|
|
params.require([ :token, :platform ])
|
|
params.permit(:token, :platform, :name).to_h.symbolize_keys
|
|
end
|
|
end
|