Skip to content

Commit 5914f76

Browse files
Merge pull request #1477 from liberu-genealogy/copilot/auto-login-user-fix-buttons
Auto-login after registration + fix clipped auth form buttons
2 parents d9cb2c1 + be9fc61 commit 5914f76

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Http\Responses\Auth;
4+
5+
use Filament\Facades\Filament;
6+
use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract;
7+
8+
class RegisterResponse implements RegisterResponseContract
9+
{
10+
public function toResponse($request): mixed
11+
{
12+
if ($request->wantsJson()) {
13+
return response()->json(['two_factor' => false]);
14+
}
15+
16+
/** @var \App\Models\User|null $user */
17+
$user = auth()->user();
18+
19+
if (! $user) {
20+
return redirect()->route('login');
21+
}
22+
23+
$panel = Filament::getPanel('app');
24+
25+
// When the panel uses tenancy and the newly registered user has no
26+
// default tenant yet, send them to the team-creation page.
27+
if ($panel->hasTenancy() && ! $user->getDefaultTenant($panel)) {
28+
return redirect('/app/new');
29+
}
30+
31+
return redirect()->intended(Filament::getUrl());
32+
}
33+
}

app/Providers/Filament/AppPanelProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ public function boot(): void
267267
\App\Http\Responses\Auth\LoginResponse::class,
268268
);
269269

270+
$this->app->singleton(
271+
\Laravel\Fortify\Contracts\RegisterResponse::class,
272+
\App\Http\Responses\Auth\RegisterResponse::class,
273+
);
274+
270275
/**
271276
* Listen and create personal team for new accounts.
272277
*/

resources/views/auth/login.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@section('content')
44
<div class="min-h-full flex flex-col sm:justify-center items-center pt-6 sm:pt-0">
5-
<div class="w-full sm:max-w-md mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
5+
<div class="w-full sm:max-w-md mt-6 px-6 py-4 bg-white shadow-md sm:rounded-lg">
66
<div class="mb-4 text-sm text-gray-600">
77
{{ __('Please sign in to access the admin panel.') }}
88
</div>

resources/views/auth/register.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@section('content')
44
<div class="min-h-full flex flex-col sm:justify-center items-center pt-6 sm:pt-0">
55

6-
<div class="w-full sm:max-w-md mb-4 mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
6+
<div class="w-full sm:max-w-md mb-4 mt-6 px-6 py-4 bg-white shadow-md sm:rounded-lg">
77
<form method="POST" action="{{ route('register') }}">
88
@csrf
99
{{-- <input type="hidden" name="_token" value="{{ csrf_token() }}"> --}}

resources/views/layouts/home.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<x-app-layout>
22
@include('components.home-navbar')
33

4-
<main class="flex-1 mt-[64px] pt-6">
4+
<main class="flex-1 pt-6">
55
@yield('content')
66
</main>
77

0 commit comments

Comments
 (0)