2026-01-20 19:53:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
refactor: organize middleware/requests into App/ subdirs, add Resources, fix auth routes
- Move middleware to App/ subdir (HandleInertiaRequests, HandleAppearance,
EnsureSubscribed, EnsureUserSetupIsComplete) matching Sendkit pattern
- Move all Form Requests into organized subdirs (App/Post, App/Workspace,
App/Media, App/Invite, App/Settings, App/Auth)
- Create AuthUserResource and AuthWorkspaceResource for HandleInertiaRequests
shared data (role inside currentWorkspace, matching Sendkit pattern)
- Split auth.php into 3 route groups (no middleware, guest, auth) matching
Sendkit pattern exactly
- Fix UserFactory to include all nullable attributes (current_workspace_id,
stripe_id, pm_type, pm_last_four, trial_ends_at)
- Fix SocialAccountResource (display_name not name)
- Update frontend for new auth prop structure
- 702 tests passing (2 pre-existing Mastodon failures)
2026-03-30 00:13:30 +00:00
|
|
|
use App\Http\Requests\App\Auth\LoginRequest;
|
2026-01-20 19:53:54 +00:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
use Inertia\Inertia;
|
|
|
|
|
use Inertia\Response;
|
|
|
|
|
|
|
|
|
|
class AuthenticatedSessionController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Display the login view.
|
|
|
|
|
*/
|
|
|
|
|
public function create(Request $request): Response
|
|
|
|
|
{
|
|
|
|
|
return Inertia::render('auth/Login', [
|
|
|
|
|
'status' => session('status'),
|
|
|
|
|
'email' => $request->query('email'),
|
|
|
|
|
'redirect' => $request->query('redirect'),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle an incoming authentication request.
|
|
|
|
|
*/
|
|
|
|
|
public function store(LoginRequest $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$request->authenticate();
|
|
|
|
|
|
|
|
|
|
$request->session()->regenerate();
|
|
|
|
|
|
|
|
|
|
// Check for redirect param
|
|
|
|
|
if ($redirect = $request->input('redirect')) {
|
2026-03-30 17:58:25 +00:00
|
|
|
// Only allow internal redirects (paths starting with /)
|
|
|
|
|
if (str_starts_with($redirect, '/') && ! str_starts_with($redirect, '//')) {
|
|
|
|
|
return redirect($redirect);
|
|
|
|
|
}
|
2026-01-20 19:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
return redirect()->intended(route('app.calendar'));
|
2026-01-20 19:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destroy an authenticated session.
|
|
|
|
|
*/
|
|
|
|
|
public function destroy(Request $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
Auth::guard('web')->logout();
|
|
|
|
|
|
|
|
|
|
$request->session()->invalidate();
|
|
|
|
|
|
|
|
|
|
$request->session()->regenerateToken();
|
|
|
|
|
|
|
|
|
|
return redirect('/');
|
|
|
|
|
}
|
|
|
|
|
}
|