pixelfed/app/Http/Middleware/EmailVerificationCheck.php

30 lines
675 B
PHP
Raw Normal View History

2018-06-14 05:30:43 +00:00
<?php
namespace App\Http\Middleware;
2018-08-28 03:07:36 +00:00
use Closure;
2018-06-14 05:30:43 +00:00
class EmailVerificationCheck
{
/**
* Handle an incoming request.
*
2018-08-28 03:07:36 +00:00
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
2018-06-14 05:30:43 +00:00
* @return mixed
*/
public function handle($request, Closure $next)
{
2018-08-28 03:07:36 +00:00
if ($request->user() &&
2018-06-14 05:30:43 +00:00
config('pixelfed.enforce_email_verification') &&
2018-08-28 03:07:36 +00:00
is_null($request->user()->email_verified_at) &&
!$request->is('i/verify-email', 'log*', 'i/confirm-email/*', 'settings/home')
2018-06-14 05:30:43 +00:00
) {
return redirect('/i/verify-email');
2018-08-28 03:07:36 +00:00
}
2018-06-14 05:30:43 +00:00
return $next($request);
}
}