Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-tharwat committed Nov 14, 2021
1 parent a1171de commit fe16dd6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/Http/Controllers/HelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,8 @@ public function manifest(){
],
];
return $manifest;
}
public function blocked_user(){
return "عفواً الحساب الخاص بك غير فعال - Sorry , Your Account Is Not Active";
}
}
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ class Kernel extends HttpKernel
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'IsAdmin' => \App\Http\Middleware\IsAdmin::class,
'ActiveAccount' => \App\Http\Middleware\ActiveAccount::class,

];
}
24 changes: 24 additions & 0 deletions app/Http/Middleware/ActiveAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class ActiveAccount
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (\Auth::check() && \Auth::user()->blocked==0) {
return $next($request);
}
return redirect('/blocked');
}
}
5 changes: 3 additions & 2 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public function run()
\App\Models\User::create([
'name'=>"ADMIN",
'power'=>"ADMIN",
'email'=>"[email protected]",
'email'=>env('DEFAULT_EMAIL'),
'email_verified_at'=>date("Y-m-d h:i:s"),
'password'=>bcrypt('password')
'password'=>bcrypt(env('DEFAULT_PASSWORD'))
]);
}
}

4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Route::get('/', function () {return view('front.index');});
//Route::get('/test',[TestController::class,'index']);

Route::prefix('admin')->middleware(['auth'])->name('admin.')->group(function () {
Route::prefix('admin')->middleware(['auth','IsAdmin','ActiveAccount'])->name('admin.')->group(function () {
Route::get('/',[AdminController::class,'index'])->name('index');

//Route::get('/profile',[AdminController::class,'upload_image']);
Expand All @@ -41,7 +41,7 @@
});



Route::get('blocked',[HelperController::class,'blocked_user'])->name('blocked');
Route::get('robots.txt',[HelperController::class,'robots']);
Route::get('manifest.json',[HelperController::class,'manifest']);
Route::get('sitemap.xml',[SiteMapController::class,'sitemap']);
Expand Down

0 comments on commit fe16dd6

Please sign in to comment.