$pathInfo = currentPathInfo(); // Get Admin Alias Path $adminAliasPath = adminAliasPath(); // Match if (substr($pathInfo, 0, strlen($adminAliasPath)) == $adminAliasPath) { // Return Response return Response::view('laravel-admin::errors.missing', array("errorTitle" => "404 Page not Found", "exception" => $exception), 404); } }); App::down(function () { // Get Path Info $pathInfo = trim(currentPathInfo(), "/"); // Allowed $allowed = false; // Check for Login Page if (currentPathUrl() == urlRoute(\Developeryamhi\AuthModule\UserItem::loginRoute(), \Developeryamhi\AuthModule\UserItem::loginRouteParams()) || currentPathUrl() == urlRoute(\Developeryamhi\AuthModule\UserItem::logoutRoute(), \Developeryamhi\AuthModule\UserItem::logoutRouteParams())) { $allowed = true; } // Check for User if (!$allowed && Auth::check() && Auth::user()->canAccess("maintainance_mode")) { $allowed = true; } // Get IPs if Setting Created $maintainance_ip_use_as = getSetting("maintainance_ip_use_as"); $maintainance_ips = getSetting("maintainance_ips"); // Check if Setting is Valid if ($maintainance_ip_use_as && $maintainance_ips && !empty($maintainance_ips)) { // IP List $ip_list = explode("\r\n", $maintainance_ips); // Current Visitor IP $currentIP = Request::getClientIp();
<?php // Apply Admin Filter Route::filter('admin', function () { if (Auth::guest()) { return Redirect::route(\Developeryamhi\AuthModule\UserItem::loginRoute(), \Developeryamhi\AuthModule\UserItem::loginRouteParams())->with('msg_error', trans("auth-module::message.must_login")); } }); // Apply Auth Filter Route::filter('auth', function () { if (Auth::guest()) { return Redirect::route(\Developeryamhi\AuthModule\UserItem::loginRoute(), \Developeryamhi\AuthModule\UserItem::loginRouteParams())->with('msg_error', trans("auth-module::message.must_login")); } }); // Apply Guest Filter Route::filter('guest', function () { if (Auth::check()) { return Redirect::route(ROUTE_DASHBOARD)->with('msg_warning', trans("auth-module::message.already_logged_in")); } }); // Apply Permission Filter Route::filter('permission', function ($route, $request, $value) { $explodes = explode("~", $value); $permissions = explode(";", $explodes[0]); $valid = Auth::check(); if ($valid) { foreach ($permissions as $permission) { if (!Auth::user()->canAccess($permission)) { $valid = false; break; }
public function doLogin() { // validate the info, create rules for the inputs $rules = array('username' => 'required|min:5', 'password' => 'required|min:6'); // run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules); // if the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->withErrors($validator)->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form } else { // create our user data for the authentication $userdata = array('username' => Input::get('username'), 'password' => Input::get('password')); // attempt to do the login if (Auth::validate($userdata)) { // Valid Login $valid_login = true; // Get User $user = UserItem::findUser($userdata["username"]); // Check if User Disabled if (!$user->isEnabled()) { return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.account_disabled")); } // Trigger Login Event & Validate mergeEventFireResponse(true, Event::fire('user.login_validate', array($user, &$valid_login))); // Check Valid if ($valid_login) { // Do Login Auth::login($user); // Add Login Log LoginLogItem::addLog($user, true); // Trigger Valid Login Event Event::fire('user.valid_login', array($user)); // validation successful! return Redirect::intended(URL::route(UserItem::dashboardRoute()))->with(FLASH_MSG_INFO, trans("auth-module::message.success_login")); } else { // Add Login Log LoginLogItem::addLog($user, false); // Trigger Invalid Login Event Event::fire('user.invalid_login', array($userdata['username'])); // validation not successful, send back to form return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password')); } } else { // Add Login Log LoginLogItem::addLogUsername($userdata["username"], false); // Trigger Invalid Login Event Event::fire('user.invalid_login', array(Input::get('username'))); // validation not successful, send back to form return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password')); } } }