Skip to content

Commit

Permalink
Update for Customized Login Page
Browse files Browse the repository at this point in the history
  • Loading branch information
afsakar committed Sep 3, 2024
1 parent 7854c22 commit 19d65ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"pest_2.35.0","defects":[],"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.354,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.004}}
{"version":"pest_2.35.0","defects":[],"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.063,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.005}}
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,40 @@ class User extends Authenticatable implements CanLoginDirectly

_*Note:* For medium and large scale applications, you only need to run "php artisan model:prune" command as cron to prevent the otp_code table from bloating and performance issues._

## Custom Login Page

If you want to customize the login page, you can extend the `\Afsakar\FilamentOtpLogin\Filament\Pages\Login` page and set your custom login page to plugin in the panel provider file with `loginPage` method.

```php
<?php

namespace App\Filament\Pages;

use Afsakar\FilamentOtpLogin\Filament\Pages\Login as OtpLogin;
use Illuminate\Contracts\Support\Htmlable;

class OverrideLogin extends OtpLogin
{
public function getHeading(): string | Htmlable
{
return 'Example Login Heading';
}
}
```

```php
use App\Filament\Pages\OverrideLogin;

public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentOtpLoginPlugin::make()
->loginPage(OverrideLogin::class),
]);
}
```

## Testing

```bash
Expand Down
11 changes: 10 additions & 1 deletion src/FilamentOtpLoginPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

class FilamentOtpLoginPlugin implements Plugin
{
public string $login = Login::class;

public function getId(): string
{
return 'filament-otp-login';
}

public function register(Panel $panel): void
{
$panel->login(Login::class);
$panel->login($this->login);
}

public function boot(Panel $panel): void
Expand All @@ -35,4 +37,11 @@ public static function get(): static

return $plugin;
}

public function loginPage(string $login): static
{
$this->login = $login;

return $this;
}
}

0 comments on commit 19d65ad

Please sign in to comment.