public function handle($request, Closure $next, $guard = null) { \App::setLocale(config('gtcmslang.defaultAdminLocale')); $showLoginMessage = true; if (config('gtcms.adminAutoLogin') && \Auth::guest()) { $user = User::where('role', 'admin')->first(); \Auth::login($user); $showLoginMessage = false; } $allowedUserRoles = config('gtcms.allowedUserRoles'); if (\Auth::guest() || !in_array(\Auth::user()->role, $allowedUserRoles)) { if (\Route::current()->uri() != "admin/login") { if (\Request::ajax() && \Request::get('getIgnore_isAjax')) { $data = array('success' => false, 'message' => "Session timeout", 'redirectToLogin' => true); return \Response::json($data); } else { return \Redirect::to('/admin/login'); } } } else { if (\Route::current()->uri() == "admin/login") { if ($showLoginMessage) { MessageManager::setError(trans('gtcms.alreadyLoggedIn')); } return \Redirect::to("/admin"); } } if (\Session::get('accessDenied')) { if (\Route::currentRouteName() != "restricted") { \Session::put('accessDenied', true); return \Redirect::to('/access-denied'); } } else { if (\Route::currentRouteName() == "restricted") { MessageManager::setError(trans('gtcms.accessGranted')); \Session::put('accessDenied', false); return \Redirect::to("/admin"); } } return $next($request); }
public function optimize() { if (\Auth::user()->is_superadmin) { if (!empty($_POST)) { if (\Request::get('formSubmit') == "Proceed") { if (\Request::get('optimizationOption') == "clearCompiledAndOptimize") { Artisan::call('clear-compiled'); Artisan::call('optimize', ['--force' => true]); MessageManager::setSuccess("Optimized class loader generated"); } else { if (\Request::get('optimizationOption') == "clearCompiled") { Artisan::call('clear-compiled'); MessageManager::setSuccess("Compiled classes cleared"); } } } return \Redirect::to("/admin"); } $data = array('active' => false, 'modelConfig' => new ModelConfig()); return \View::make("gtcms.admin.elements.optimizationOptions")->with($data); } else { \Session::set('accessDenied', true); return self::restricted(); } }
public static function showMessages() { $messages = ""; if ($msg = MessageManager::getException()) { $messages .= '<div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> ' . $msg . ' </div>'; } if ($msg = MessageManager::getError()) { $messages .= '<div class="alert alert-warning alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> ' . $msg . ' </div>'; } if ($msg = MessageManager::getSuccess()) { $messages .= '<div class="alert alert-info alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> ' . $msg . ' </div>'; } return $messages; }