pp-planer/app/Http/Controllers/AuthController.php
Thorsten Bus d5f3990f3b fix: login redirect, nametag/worship resolution, macros, export headers & probundle
- Post-login (OAuth + dev-login) now redirects to the next upcoming
  service's edit page instead of /dashboard, mirroring the GET / route.
- NameTagResolver now reads the real ChurchTools `responsible` shape
  (persons[].person.title) and resolves moderator/preacher/worship-leader
  by responsible ROLE ([Moderation]/[Predigt]/[Lobpreis]). This fixes
  missing name slides and makes the worship-leader arrangement trigger
  (e.g. service 12 → "Benedikt Hardt" / "Jennifer Schneider").
- NameTagSlideBuilder no longer silently drops the name slide when the
  configured macro id points to a missing macro; it emits the slide
  without a macro instead.
- Song export: the "first slide" / "last slide" macro now applies only to
  the song's very first/last slide (global slide index across all
  sections), not the first slide of every section.
- Export "headlines" for content-less agenda items are now emitted as
  proper ProPresenter playlist HEADER items instead of text presentations.
- Prefix/postfix export files now also accept .probundle (unzipped: inner
  .pro + media embedded) in addition to .pro, both for upload validation
  and export injection.

Full suite green (587 passed).
2026-06-01 22:17:31 +02:00

77 lines
2.1 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Service;
use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use Inertia\Response;
use Laravel\Socialite\Facades\Socialite;
class AuthController extends Controller
{
/**
* Zeige die Login-Seite.
*/
public function showLogin(): Response
{
return Inertia::render('Auth/Login', [
'canDevLogin' => app()->environment('local', 'testing'),
]);
}
/**
* Leite den Benutzer zu ChurchTools OAuth weiter.
*/
public function redirect(): RedirectResponse|\Symfony\Component\HttpFoundation\RedirectResponse
{
return Socialite::driver('churchtools')->redirect();
}
/**
* Verarbeite den OAuth-Callback von ChurchTools.
*/
public function callback(): RedirectResponse
{
$socialiteUser = Socialite::driver('churchtools')->user();
$rawUser = $socialiteUser->user ?? [];
$user = User::updateOrCreate(
['email' => $socialiteUser->getEmail()],
[
'name' => $socialiteUser->getName(),
'churchtools_id' => (int) ($rawUser['id'] ?? $socialiteUser->getId()),
'avatar' => $socialiteUser->getAvatar() ?? ($rawUser['imageUrl'] ?? null),
'churchtools_groups' => $rawUser['groups'] ?? [],
'churchtools_roles' => $rawUser['roles'] ?? [],
'password' => '',
],
);
Auth::login($user, remember: true);
$service = Service::nextUpcoming()->first();
$target = $service
? route('services.edit', $service->id)
: route('services.index');
return redirect()->intended($target);
}
/**
* Melde den Benutzer ab.
*/
public function logout(Request $request): RedirectResponse
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/login');
}
}