-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4801 from RoboJackets/kristaps/shared-device-role
Add shared-device role to allow accounts to bypass authentication checks
- Loading branch information
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
database/migrations/2024_09_08_203808_add_shared_device_role.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Spatie\Permission\Models\Permission; | ||
use Spatie\Permission\Models\Role; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
app()['cache']->forget('spatie.permission.cache'); | ||
|
||
$create_attendance = Permission::firstOrCreate(['name' => 'create-attendance']); | ||
$read_events = Permission::firstOrCreate(['name' => 'read-events']); | ||
$read_teams = Permission::firstOrCreate(['name' => 'read-teams']); | ||
$read_teams_hidden = Permission::firstOrCreate(['name' => 'read-teams-hidden']); | ||
$read_users = Permission::firstOrCreate(['name' => 'read-users']); | ||
|
||
$shared_device = Role::firstOrCreate(['name' => 'shared-device']); | ||
|
||
$shared_device->givePermissionTo($create_attendance); | ||
$shared_device->givePermissionTo($read_events); | ||
$shared_device->givePermissionTo($read_teams); | ||
$shared_device->givePermissionTo($read_teams_hidden); | ||
$shared_device->givePermissionTo($read_users); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
app()['cache']->forget('spatie.permission.cache'); | ||
|
||
Role::where('name', 'shared-device')->delete(); | ||
} | ||
}; |