forked from mirror/pixelfed
Update middleware, add AccountInterstitial support
This commit is contained in:
parent
b8330b3d92
commit
19d6e7df65
3 changed files with 58 additions and 1 deletions
|
@ -66,6 +66,7 @@ class Kernel extends HttpKernel
|
|||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'twofactor' => \App\Http\Middleware\TwoFactorAuth::class,
|
||||
'validemail' => \App\Http\Middleware\EmailVerificationCheck::class,
|
||||
'interstitial' => \App\Http\Middleware\AccountInterstitial::class,
|
||||
// 'restricted' => \App\Http\Middleware\RestrictedAccess::class,
|
||||
];
|
||||
}
|
||||
|
|
48
app/Http/Middleware/AccountInterstitial.php
Normal file
48
app/Http/Middleware/AccountInterstitial.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
use App\User;
|
||||
|
||||
class AccountInterstitial
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$ar = [
|
||||
'login',
|
||||
'logout',
|
||||
'password*',
|
||||
'loginAs*',
|
||||
'i/warning*',
|
||||
'i/auth/checkpoint',
|
||||
'i/auth/sudo',
|
||||
'site/privacy',
|
||||
'site/terms',
|
||||
'site/kb/community-guidelines',
|
||||
];
|
||||
|
||||
if(Auth::check() && !$request->is($ar)) {
|
||||
if($request->user()->has_interstitial) {
|
||||
if($request->wantsJson()) {
|
||||
$res = ['_refresh'=>true,'error' => 403, 'message' => \App\AccountInterstitial::JSON_MESSAGE];
|
||||
return response()->json($res, 403);
|
||||
} else {
|
||||
return redirect('/i/warning');
|
||||
}
|
||||
} else {
|
||||
return $next($request);
|
||||
}
|
||||
} else {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,9 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio
|
|||
Route::get('reports/show/{id}', 'AdminController@showReport');
|
||||
Route::post('reports/show/{id}', 'AdminController@updateReport');
|
||||
Route::post('reports/bulk', 'AdminController@bulkUpdateReport');
|
||||
Route::get('reports/appeals', 'AdminController@appeals');
|
||||
Route::get('reports/appeal/{id}', 'AdminController@showAppeal');
|
||||
Route::post('reports/appeal/{id}', 'AdminController@updateAppeal');
|
||||
Route::redirect('statuses', '/statuses/list');
|
||||
Route::get('statuses/list', 'AdminController@statuses')->name('admin.statuses');
|
||||
Route::get('statuses/show/{id}', 'AdminController@showStatus');
|
||||
|
@ -73,7 +76,7 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio
|
|||
Route::post('newsroom/create', 'AdminController@newsroomStore');
|
||||
});
|
||||
|
||||
Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofactor', 'localization'])->group(function () {
|
||||
Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofactor', 'localization','interstitial'])->group(function () {
|
||||
Route::get('/', 'SiteController@home')->name('timeline.personal');
|
||||
Route::post('/', 'StatusController@store');
|
||||
|
||||
|
@ -125,6 +128,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('discover/tag', 'DiscoverController@getHashtags');
|
||||
Route::post('status/compose', 'InternalApiController@composePost')->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'pixelfed'], function() {
|
||||
Route::group(['prefix' => 'v1'], function() {
|
||||
Route::get('accounts/verify_credentials', 'ApiController@verifyCredentials');
|
||||
|
@ -169,6 +173,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('discover/posts/places', 'DiscoverController@trendingPlaces');
|
||||
});
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'local'], function () {
|
||||
// Route::get('accounts/verify_credentials', 'ApiController@verifyCredentials');
|
||||
// Route::get('accounts/relationships', 'PublicApiController@relationships');
|
||||
|
@ -295,6 +300,9 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('redirect', 'SiteController@redirectUrl');
|
||||
Route::post('admin/media/block/add', 'MediaBlocklistController@add');
|
||||
Route::post('admin/media/block/delete', 'MediaBlocklistController@delete');
|
||||
|
||||
Route::get('warning', 'AccountInterstitialController@get');
|
||||
Route::post('warning', 'AccountInterstitialController@read');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'account'], function () {
|
||||
|
|
Loading…
Reference in a new issue