public function run()
 {
     $adminGroup = GroupItem::findGroup(adminGroup());
     if ($adminGroup) {
         UserItem::create(array('group_id' => $adminGroup->id, 'full_name' => 'Admin User', 'username' => 'admin', 'email' => '*****@*****.**', 'password' => Hash::make('password')));
     }
 }
Exemplo n.º 2
0
 public static function collectUsers($key, $value)
 {
     $user_ids = self::collectUserIds($key, $value);
     if (sizeof($user_ids) < 1) {
         return array();
     }
     return UserItem::whereIn('id', $user_ids)->select(DB::raw('concat (first_name, " ", last_name) as full_name,id'))->lists("full_name", "id");
 }
Exemplo n.º 3
0
<?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 userLists()
 {
     $items = array();
     $query = UserItem::select(array("id", "group_id", "full_name", "username"));
     //->filterNotGroup(adminGroup());
     if (Input::has("user_type") && Input::get("user_type") != "*") {
         $query->filterGroup(Input::get("user_type"));
     }
     if (Input::has("_term")) {
         $term = Input::get("_term");
         $query->whereRaw(DB::raw("(full_name like '%{$term}%' OR username like '%{$term}%' OR full_name like '{$term}%' OR username like '{$term}%')"));
     }
     foreach ($query->get() as $user) {
         $items[] = array("id" => $user->id, "group" => $user->group()->group_description, "full_name" => $user->full_name, "username" => $user->username);
     }
     return Response::json($items);
 }
Exemplo n.º 5
0
    $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();
 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'));
         }
     }
 }