protected static function current_user() { // -------------------------------------------------------------- // For Layla // -------------------------------------------------------------- return Auth::user() ?: new Account(); // -------------------------------------------------------------- // End for Layla // -------------------------------------------------------------- }
public static function arrayRoles() { $rolelist = Role::all(); $arrayRole = array(); foreach ($rolelist as $value) { if (Auth::check() && Auth::user()->role != 1 && $value->roleid != 1) { $arrayRole[$value->roleid] = $value->role; } else { $arrayRole[$value->roleid] = $value->role; } } return $arrayRole; }
/** * Test the Auth::logout method. * * @group laravel */ public function testLogoutMethodLogsOutUser() { Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1; Auth::logout(); // A workaround since Cookie will is only stored in memory, until Response class is called. Auth::driver()->token = null; $this->assertNull(Auth::user()); $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login'])); $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time()); }
public static function remData($id) { Cat::find($id)->delete(); Log::write('Data', 'Claims Category Id <b>' . $id . '</b> Remove by ' . Auth::user()->username); }
/** * Test the Auth::logout method. * * @group laravel */ public function testLogoutMethodLogsOutUser() { Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1; Auth::logout(); $this->assertNull(Auth::user()); $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login'])); $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time()); }
/** * Removing Data Information * * @return void * @author **/ public static function remData($id) { Content::find($id)->delete(); Log::write('Data', 'Data Id <b>' . $id . '</b> Remove by ' . Auth::user()->username); }
/** * Delete all expired sessions from persistent storage. * * @param int $expiration * @return void */ public function sweep($expiration) { $expiration = Request::time() - Config::get('o_timeout_online'); // Fetch all sessions that are older than o_timeout_online $result = $this->table()->where('user_id', '!=', 1)->where('last_visit', '<', $expiration)->get(); $delete_ids = array(); foreach ($result as $cur_session) { $delete_ids[] = $cur_session->id; $result = $this->connection->table('users')->where_id($cur_session->user_id)->update(array('last_visit' => $cur_session->last_visit)); } // Make sure logged-in users have no more than ten sessions alive if (Auth::check()) { $uid = User::current()->id; $session_ids = $this->table()->where_user_id($uid)->order_by('last_visit', 'desc')->lists('id'); $prune_ids = array_slice($session_ids, 10); $delete_ids = array_merge($delete_ids, $prune_ids); } if (!empty($delete_ids)) { $this->table()->where_in('id', $delete_ids)->or_where('last_visit', '<', $expiration)->delete(); } }
public static function updateUser($input) { $user = User::find($input['userid']); $profileid = $user->userprofile->profileid; $user->role = $input['role']; $user->status = $input['status']; $user->save(); $prof = array(array('fullname' => $input['fullname'], 'icno' => $input['icno'], 'emel' => $input['emel'])); $profile = Profile::find($profileid); $profile->fullname = $input['fullname']; $profile->icno = $input['icno']; $profile->emel = $input['emel']; $profile->save(); $profile = User::find($input['userid']); Log::write('User', 'Update User ' . $user->userprofile->icno . 'By ' . Auth::user()->username); }
protected static function current_user() { return Auth::user() ?: new User(); }
/** * Test `laravel.auth: login` and `laravel.auth: logout` is called properly * * @group laravel */ public function testAuthEventIsCalledProperly() { Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); Event::listen('laravel.auth: login', function () { $_SERVER['test.user.login'] = '******'; }); Event::listen('laravel.auth: logout', function () { $_SERVER['test.user.logout'] = 'foo'; }); $this->assertNull($_SERVER['test.user.login']); $this->assertNull($_SERVER['test.user.logout']); Auth::login(1, true); $this->assertEquals('foo', $_SERVER['test.user.login']); Auth::logout(); $this->assertEquals('foo', $_SERVER['test.user.logout']); }