Skip to content

Fix issue with 2 accounts signed in on the same device #83

@kofimokome

Description

@kofimokome

Since the device_uuid is persistent per device, if two accounts are accessed from the same device, an error occurrs due to duplicate tokens in the devices table.

Solution 1

Use a composite key (token, deviceable_id, deviceable_type) to uniquely identify a device

Solution 2

Use a pivot table to solve this problem. The proposed schema for the pivot table is shown below

Schema::create('device_assignments', function (Blueprint $table) {
    $table->id();
    $table->foreignId('device_id')->constrained()->onDelete('cascade');
    $table->morphs('deviceable'); // deviceable_id + deviceable_type
    $table->timestamps();

    $table->unique(['device_id', 'deviceable_id', 'deviceable_type']); // avoid duplicates
});

the package can provide a way to link a device to any other model via assignments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions