29 lines
776 B
PHP
29 lines
776 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Models\User;
|
|
|
|
class VerificationController extends Controller
|
|
{
|
|
public function verify(Request $request, $id, $hash)
|
|
{
|
|
$user = User::find($id);
|
|
|
|
if (!$user || !hash_equals((string) $hash, sha1($user->email))) {
|
|
return redirect('/login')->with('error', 'Invalid verification link.');
|
|
}
|
|
|
|
if ($user->hasVerifiedEmail()) {
|
|
return redirect('/login')->with('info', 'Email already verified.');
|
|
}
|
|
|
|
$user->markEmailAsVerified();
|
|
$user->status = 1;
|
|
$user->save();
|
|
|
|
return redirect('/login')->with('success', 'Email verified successfully. You can now log in.');
|
|
}
|
|
} |