Sistema de controles da União de Ciclistas do Brasil
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

34 lines
1016 B

<?php
namespace App\Http\Controllers\Collaborators\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\RedirectResponse;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Access\AuthorizationException;
class EmailVerificationController extends Controller
{
public function __invoke(string $id, string $hash): RedirectResponse
{
if (!hash_equals((string) $id, (string) Auth::user()->getKey())) {
throw new AuthorizationException();
}
if (!hash_equals((string) $hash, sha1(Auth::user()->getEmailForVerification()))) {
throw new AuthorizationException();
}
if (Auth::user()->hasVerifiedEmail()) {
return redirect(route('collaborators.dashboard'));
}
if (Auth::user()->markEmailAsVerified()) {
event(new Verified(Auth::user()));
}
return redirect(route('collaborators.dashboard'));
}
}