lms/app/Http/Controllers/Auth/EmailVerificationNotificationController.php
Ahmed Darrazi 0aa2081a1d
All checks were successful
Build & Push Docker Image / docker (push) Successful in 1m49s
Übersetze Mail-Vorlagen ins Deutsche (du-Form)
2025-12-18 21:33:01 +01:00

59 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateEmailRequest;
use App\Services\AccountService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class EmailVerificationNotificationController extends Controller
{
public function __construct(private AccountService $accountService) {}
/**
* Send a new email verification notification.
*/
public function store(Request $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false));
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
}
/**
* Send a new email for verify the new email.
*/
public function update(UpdateEmailRequest $request)
{
$this->accountService->changeEmail($request->validated(), Auth::user()->id);
return back()->with('success', 'Wir haben einen Bestätigungslink an deine neue E-Mail-Adresse gesendet.');
}
/**
* Update the specified resource in storage.
*/
public function save(Request $request)
{
$user = Auth::user();
$saved = $this->accountService->saveChangedEmail($request->token, $user->id);
$flash = $saved ? 'success' : 'error';
$message = $saved ? 'Die EMail wurde erfolgreich geändert.' : 'Der Bestätigungs-Token stimmt nicht oder ist abgelaufen.';
if ($user->role == 'student') {
return redirect()->route('student.index', ['tab' => 'settings'])
->with($flash, $message);
}
return redirect()->route('settings.account')
->with($flash, $message);
}
}