Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/Filament/Pages/Auth/EditProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ protected function getDefaultTabs(): array
->map(fn (MultiFactorAuthenticationProvider $multiFactorAuthenticationProvider) => Group::make($multiFactorAuthenticationProvider->getManagementSchemaComponents())
->statePath($multiFactorAuthenticationProvider->getId()))
->all()),
Tab::make('passkeys')
->label(trans('profile.tabs.passkeys'))
->icon(TablerIcon::Fingerprint)
->schema([
Section::make(trans('profile.tabs.passkeys'))
->description(trans('passkeys.description'))
->schema([
Group::make([
view('passkeys.livewire.passkeys-tab'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should be adding a view like this. iirc there is a View component from filament.

]),
]),
]),
Tab::make('api_keys')
->label(trans('profile.tabs.api_keys'))
->icon(TablerIcon::Key)
Expand Down
63 changes: 63 additions & 0 deletions app/Livewire/Passkeys.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.


namespace App\Livewire;

use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Notifications\Notification;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Illuminate\View\View;
use Spatie\LaravelPasskeys\Livewire\PasskeysComponent;

final class Passkeys extends PasskeysComponent implements HasActions, HasSchemas
{
use InteractsWithActions;
use InteractsWithSchemas;

public function confirmDelete(int $passkeyId): void
{
$this->mountAction('deleteAction', ['passkey' => $passkeyId]);
}

public function deleteAction(): Action
{
return Action::make('deleteAction')
->label(trans('passkeys.delete'))
->color('danger')
->requiresConfirmation()
->action(fn (array $arguments) => $this->deletePasskey((int) $arguments['passkey']));
}

public function deletePasskey(int $passkeyId): void
{
$this->currentUser()->passkeys()->findOrFail($passkeyId);

parent::deletePasskey($passkeyId);

Notification::make()
->title(trans('passkeys.deleted_notification_title'))
->success()
->send();
}

public function storePasskey(string $passkey): void
{
parent::storePasskey($passkey);

Notification::make()
->title(trans('passkeys.created_notification_title'))
->success()
->send();
}

public function render(): View
{
return view('passkeys.livewire.passkeys', data: [
'passkeys' => $this->currentUser()->passkeys()->get(),
]);
}
}
15 changes: 14 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
use Illuminate\Support\Str;
use Illuminate\Validation\Rules\In;
use ResourceBundle;
use Spatie\LaravelPasskeys\Models\Concerns\HasPasskeys;
use Spatie\LaravelPasskeys\Models\Concerns\InteractsWithPasskeys;
use Spatie\Permission\Traits\HasRoles;

/**
Expand Down Expand Up @@ -94,7 +96,7 @@
* @method static Builder|User whereUsername($value)
* @method static Builder|User whereUuid($value)
*/
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, FilamentUser, HasAppAuthentication, HasAppAuthenticationRecovery, HasAvatar, HasEmailAuthentication, HasName, HasTenants, Validatable
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, FilamentUser, HasAppAuthentication, HasAppAuthenticationRecovery, HasAvatar, HasEmailAuthentication, HasName, HasPasskeys, HasTenants, Validatable
{
use Authenticatable;
use Authorizable { can as protected canned; }
Expand All @@ -103,6 +105,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
use HasFactory;
use HasRoles;
use HasValidation { getRules as getValidationRules; }
use InteractsWithPasskeys;
use Notifiable;

public const USER_LEVEL_USER = 0;
Expand Down Expand Up @@ -504,4 +507,14 @@ public function toggleEmailAuthentication(bool $condition): void
{
$this->update(['mfa_email_enabled' => $condition]);
}

public function getPasskeyDisplayName(): string
{
return $this->username ?? $this->email;
}

public function getPasskeyUserId(): int
{
return $this->id;
}
}
7 changes: 7 additions & 0 deletions app/Providers/Filament/FilamentServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Enums\CustomizationKey;
use App\Enums\TablerIcon;
use App\Livewire\Passkeys;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
Expand Down Expand Up @@ -64,6 +65,11 @@ public function boot(): void
fn () => Blade::render('filament.layouts.footer'),
);

FilamentView::registerRenderHook(
PanelsRenderHook::AUTH_LOGIN_FORM_AFTER,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need a render hook for the login form, we already have a custom login page.
Same goes for all the blade views.

fn () => view('passkeys.login'),
);

FilamentView::registerRenderHook(
PanelsRenderHook::STYLES_BEFORE,
fn () => Blade::render("@vite(['resources/css/app.css'])")
Expand Down Expand Up @@ -257,6 +263,7 @@ public function boot(): void

SchemaIconAlias::COMPONENTS_WIZARD_COMPLETED_STEP => TablerIcon::Check,
]);
Livewire::component('filament-passkeys', Passkeys::class);
}

public function register(): void {}
Expand Down
3 changes: 1 addition & 2 deletions app/Services/Activity/ActivityLogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Contracts\Auth\Factory as AuthFactory;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Request;
use Throwable;
Expand Down Expand Up @@ -71,7 +70,7 @@ public function description(?string $description): self
*/
public function subject(...$subjects): self
{
foreach (Arr::wrap($subjects) as $subject) {
foreach ($subjects as $subject) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change?

Copy link
Contributor Author

@JoanFo1456 JoanFo1456 Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, that was a laravel bug and fixed with #2167

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using main the day I made passkeys with the latest changes, then how is it possible to fail?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must have done composer upgrade as it updated to v12.50 which is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must have done composer upgrade as it updated to v12.50 which is broken.

I didn't, i just made a require to spatie's passkeys.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this needs to be a giant discussion. Require 12.49 , revert this change, and be done with it.

if (is_null($subject)) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"spatie/laravel-data": "^4.19",
"spatie/laravel-fractal": "^6.3",
"spatie/laravel-health": "^1.34",
"spatie/laravel-passkeys": "^1.5",
"spatie/laravel-permission": "^6.24",
"spatie/laravel-query-builder": "^6.4",
"spatie/temporary-directory": "^2.3",
Expand Down
Loading