-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Joel Butcher <[email protected]>
- Loading branch information
1 parent
24ca011
commit 9682337
Showing
48 changed files
with
1,626 additions
and
41 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
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,44 @@ | ||
<?php | ||
|
||
namespace Cachet\Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Str; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Cachet\Models\User> | ||
*/ | ||
class UserFactory extends Factory | ||
{ | ||
/** | ||
* The current password being used by the factory. | ||
*/ | ||
protected static ?string $password; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function definition(): array | ||
{ | ||
return [ | ||
'name' => fake()->name(), | ||
'email' => fake()->unique()->safeEmail(), | ||
'email_verified_at' => now(), | ||
'password' => static::$password ??= Hash::make('password'), | ||
'remember_token' => Str::random(10), | ||
]; | ||
} | ||
|
||
/** | ||
* Indicate that the model's email address should be unverified. | ||
*/ | ||
public function unverified(): static | ||
{ | ||
return $this->state(fn (array $attributes) => [ | ||
'email_verified_at' => null, | ||
]); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
database/migrations/2025_01_11_090556_create_api_keys_table.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,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('api_keys', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name')->unique(); | ||
$table->string('token_', 64)->unique(); | ||
$table->foreignId('user_id')->constrained()->onDelete('cascade'); | ||
$table->timestamp('last_used_at')->nullable(); | ||
$table->timestamp('expires_at')->nullable(); | ||
$table->boolean('revoked_at')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('api_keys'); | ||
} | ||
}; |
28 changes: 28 additions & 0 deletions
28
database/migrations/2025_01_15_121008_add_admin_flag_to_users_table.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,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->boolean('is_admin')->default(false); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->dropColumn('is_admin'); | ||
}); | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -50,6 +50,7 @@ public function run(): void | |
'email' => '[email protected]', | ||
'password' => bcrypt('test123'), | ||
'email_verified_at' => now(), | ||
'is_admin' => true, | ||
]); | ||
|
||
Schedule::create([ | ||
|
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,7 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: '#^Access to an undefined property Laravel\\Sanctum\\PersonalAccessToken\:\:\$expires_at\.$#' | ||
identifier: property.notFound | ||
count: 3 | ||
path: src/Filament/Resources/ApiKeyResource.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
includes: | ||
- vendor/larastan/larastan/extension.neon | ||
- phpstan-baseline.neon | ||
|
||
parameters: | ||
level: 5 | ||
|
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,31 @@ | ||
<?php | ||
|
||
return [ | ||
'resource_label' => 'API Key|API Keys', | ||
'show_token' => [ | ||
'heading' => 'Your API Token has been generated', | ||
'description' => 'Please copy your new API token. For your security, it won\'t be shown again.', | ||
'copy_tooltip' => 'Token copied!', | ||
], | ||
'abilities_label' => ':ability :resource', | ||
'form' => [ | ||
'name_label' => 'Token Name', | ||
'expires_at_label' => 'Expires At', | ||
'expires_at_helper' => 'Expires at midnight. Leave empty for no expiry', | ||
'expires_at_validation' => 'The expiry date must be in the future', | ||
'abilities_label' => 'Permissions', | ||
'abilities_hint' => 'Leaving this empty will give the token full permissions', | ||
], | ||
'list' => [ | ||
'actions' => [ | ||
'revoke' => 'Revoke', | ||
], | ||
'headers' => [ | ||
'name' => 'Token Name', | ||
'abilities' => 'Permissions', | ||
'created_at' => 'Created At', | ||
'expires_at' => 'Expires At', | ||
'updated_at' => 'Updated At', | ||
], | ||
], | ||
]; |
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
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,27 @@ | ||
<x-filament::page> | ||
@if($token = session('api-token')) | ||
<x-filament::section :heading="__('cachet::api_key.show_token.heading')"> | ||
<p class="text-sm leading-6 text-gray-500 dark:text-gray-400"> | ||
{{ __('cachet::api_key.show_token.description') }} | ||
</p> | ||
|
||
<div class="flex items-center gap-3 mt-3"> | ||
<div | ||
style="--c-50:var(--success-50);--c-400:var(--success-400);--c-600:var(--success-600);" | ||
class="fi-badge cursor-pointer inline-block rounded-md px-3 py-2 text-sm ring-1 ring-inset min-w-[theme(spacing.6)] fi-color-custom bg-custom-50 text-custom-600 ring-custom-600/10 dark:bg-custom-400/10 dark:text-custom-400 dark:ring-custom-400/30 fi-color-success" | ||
x-on:click=" | ||
window.navigator.clipboard.writeText(@js($token)) | ||
$tooltip(@js(__('cachet::api_key.show_token.copy_tooltip')), { | ||
theme: $store.theme, | ||
timeout: 2000, | ||
}) | ||
" | ||
> | ||
{{ $token }} | ||
</div> | ||
</div> | ||
</x-filament::section> | ||
@endsession | ||
|
||
{{ $this->table }} | ||
</x-filament::page> |
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
Oops, something went wrong.