inital commit
This commit is contained in:
25
app/Http/Middleware/AuditorCheckMiddleware.php
Normal file
25
app/Http/Middleware/AuditorCheckMiddleware.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuditorCheckMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (Auth::check() && Auth::user()->hasRole('Auditor')) {
|
||||
return redirect('/cmms-audit');
|
||||
}
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
}
|
||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('rmtologin');
|
||||
}
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/CheckForMaintenanceMode.php
Normal file
17
app/Http/Middleware/CheckForMaintenanceMode.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
91
app/Http/Middleware/ConfirmUserMiddleware.php
Normal file
91
app/Http/Middleware/ConfirmUserMiddleware.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class ConfirmUserMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// if (Auth::check() && Route::current()->uri == 'loginkarbar') {
|
||||
// return true;
|
||||
// }
|
||||
// dd(Auth::user());
|
||||
|
||||
|
||||
// for migrate
|
||||
|
||||
$usernames_list = [
|
||||
"witel",
|
||||
"amiriis",
|
||||
"drdanesh",
|
||||
"khuzestanoffice",
|
||||
"alborzoffice",
|
||||
"ardabiloffice",
|
||||
"azarbayjangharbioffice",
|
||||
"azarbayjansharghioffice",
|
||||
"bushehroffice",
|
||||
"chaharmahalvabakhtiarioffice",
|
||||
"farsoffice",
|
||||
"ghazvinoffice",
|
||||
"gilanoffice",
|
||||
"golestanoffice",
|
||||
"hamedanoffice",
|
||||
"hormozganoffice",
|
||||
"ilamoffice",
|
||||
"iranshahroffice",
|
||||
"isfahanoffice",
|
||||
"kermanjonuboffice",
|
||||
"kermanoffice",
|
||||
"kermanshahoffice",
|
||||
"khorasanjonubioffice",
|
||||
"khorasanrazavioffice",
|
||||
"khorasanshomalioffice",
|
||||
"khuzestanoffice",
|
||||
"kohgiluyehvaboyerahmadoffice",
|
||||
"kordestanoffice",
|
||||
"larestanoffice",
|
||||
"lorestanoffice",
|
||||
"markazioffice",
|
||||
"mazandaranoffice",
|
||||
"qomoffice",
|
||||
"semnangharboffice",
|
||||
"semnansharghoffice",
|
||||
"sistanvabaluchestanoffice",
|
||||
"tehranoffice",
|
||||
"yazdoffice",
|
||||
"zanjanoffice",
|
||||
|
||||
"pardis",
|
||||
"ahvaz",
|
||||
"birjand",
|
||||
];
|
||||
// if (Auth::check() && !in_array(Auth::user()->username, $usernames_list)) {
|
||||
// return abort(503);
|
||||
// }
|
||||
|
||||
// for migrate
|
||||
|
||||
|
||||
if (Auth::check() && !Auth::user()->enabled) {
|
||||
return abort(455);
|
||||
}
|
||||
|
||||
if (Auth::check() && Auth::user()->confirmed == 0 && !preg_match('/^valid(.*)/m', Route::current()->uri) && !preg_match('/^logout(.*)/m', Route::current()->uri)) {
|
||||
return redirect('/valid/loginkarbar');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
31
app/Http/Middleware/Cors.php
Normal file
31
app/Http/Middleware/Cors.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class Cors
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$handle = $next($request);
|
||||
if(method_exists($handle, 'header'))
|
||||
{
|
||||
$handle->header('Access-Control-Allow-Origin' , '*')
|
||||
->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')
|
||||
->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, Application');
|
||||
}
|
||||
return $handle;
|
||||
|
||||
return $next($request)
|
||||
->header('Access-Control-Allow-Origin', '*')
|
||||
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||
}
|
||||
}
|
||||
44
app/Http/Middleware/CsrfLoginDev.php
Normal file
44
app/Http/Middleware/CsrfLoginDev.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use App\Models\User;
|
||||
|
||||
class CsrfLoginDev
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
// dd('ddd')
|
||||
// auth()->loginUsingId(User::where('username', 'witel')->first()->id);
|
||||
// // dd(csrf_token());
|
||||
// // $request->headers->set('X-CSRF-TOKEN', csrf_token());
|
||||
// // dd($request->headers);
|
||||
// $handle = $next($request->request->add(['_token' => csrf_token()]));
|
||||
// // $handle->header('X-CSRF-TOKEN', csrf_token());
|
||||
// // if(method_exists($handle, 'header'))
|
||||
// // {
|
||||
// // $handle->header('Access-Control-Allow-Origin' , '*')
|
||||
// // ->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')
|
||||
// // ->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, Application');
|
||||
// // }
|
||||
// return $handle;
|
||||
// return $next($request)->header('X-CSRF-TOKEN', csrf_token());
|
||||
// dd($request->secure());
|
||||
dd(url()->current());
|
||||
// if (!$request->secure()) {
|
||||
// dd(1);
|
||||
return redirect()->secure($request->getRequestUri());
|
||||
// }
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
34
app/Http/Middleware/LogRoute.php
Normal file
34
app/Http/Middleware/LogRoute.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LogRoute
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
if (app()->environment('local')) {
|
||||
$log = [
|
||||
'URI' => $request->getUri(),
|
||||
'METHOD' => $request->getMethod(),
|
||||
'REQUEST_BODY' => $request->all(),
|
||||
'RESPONSE' => $response->getContent()
|
||||
];
|
||||
|
||||
Log::info(json_encode($log));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
49
app/Http/Middleware/RandDRedirectMiddleware.php
Normal file
49
app/Http/Middleware/RandDRedirectMiddleware.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
class RandDRedirectMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
// if (Auth::check()){
|
||||
// $user = Auth::user();
|
||||
|
||||
// // if ($user->isRandDMember() && !preg_match('/^RandD(.*)/m', Route::current()->uri)) {
|
||||
// // return redirect('RandD');
|
||||
// // }
|
||||
|
||||
// // if($user->permissions()->where('type','randd')->get()->count() == 0 && preg_match('/^RandD(.*)/m', Route::current()->uri)){
|
||||
|
||||
// // // dd(Route::current()->uri);
|
||||
// // return abort(403);
|
||||
// // }
|
||||
|
||||
// if ($user->hasRole('auditor')) {
|
||||
// return redirect('/cmms-audit');
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (Auth::check() && Auth::user()->hasRole('RandD')) {
|
||||
// return redirect('/RandD');
|
||||
// }
|
||||
// if (Auth::check() && Auth::user()->hasRole('auditor')) {
|
||||
// return redirect('/cmms-audit');
|
||||
// }
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
}
|
||||
27
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
27
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('rmto');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
18
app/Http/Middleware/TrimStrings.php
Normal file
18
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
34
app/Http/Middleware/VerifyCsrfToken.php
Normal file
34
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $addHttpCookie = true;
|
||||
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'public/cmms-download',
|
||||
'cmms/create',
|
||||
'webapi/contracts/setad',
|
||||
'webapi/contracts/eblagh',
|
||||
'webapi/request',
|
||||
'webapi/set-online',
|
||||
'webapi/set-offline',
|
||||
'webapi/profile/edit',
|
||||
'webapi/camp/*',
|
||||
'webapi/*',
|
||||
'users/change_confirmed_status'
|
||||
];
|
||||
}
|
||||
23
app/Http/Middleware/md_HttpsProtocol.php
Normal file
23
app/Http/Middleware/md_HttpsProtocol.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class HttpsProtocol
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$request->secure()) {
|
||||
return redirect()->secure($request->getRequestUri());
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user