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) &&
|
2019-09-01 23:54:06 +00:00
|
|
|
!$request->is(
|
2020-08-16 05:37:10 +00:00
|
|
|
'i/auth/*',
|
2019-09-01 23:54:06 +00:00
|
|
|
'i/verify-email',
|
|
|
|
'log*',
|
|
|
|
'i/confirm-email/*',
|
|
|
|
'settings/home',
|
|
|
|
'settings/email'
|
|
|
|
)
|
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);
|
|
|
|
}
|
|
|
|
}
|