<?php include './resources/init.php'; if (isset($_POST['type'])) { if ($_POST['type'] == "logout") { fAuthorization::destroyUserInfo(); } else { if ($_POST['type'] == "login") { try { $user = new User($_POST['username']); } catch (fException $e) { fURL::redirect(URL_ROOT . "authentication.php"); } if (sha1($_POST['password']) == $user->getPassword()) { fAuthorization::setUserAuthLevel($user->getLevel()); fAuthorization::setUserToken($_POST['username']); fURL::redirect(fAuthorization::getRequestedUrl(true, URL_ROOT . "inventory.php")); } else { fURL::redirect(URL_ROOT . "authentication.php"); } } } } else { if (isset($_GET['type']) == "logout") { fAuthorization::destroyUserInfo(); } } $tmpl->place('header'); $tmpl->place('menu'); ?> <div class="span-24 last">
fAuthorization::setUserAuthLevel('super'); break; case 2: fAuthorization::setUserAuthLevel('admin'); break; case 3: case 4: case 5: case 6: case 7: case 8: fAuthorization::setUserAuthLevel('employee'); break; case 9: default: fAuthorization::setUserAuthLevel('guest'); break; } $up = new UserPermission(); $tmp = $up->getByIdUser($u->prepareIdUser()); $permissions = array('banner' => array(), 'news' => array(), 'classified' => array(), 'social' => array(), 'poll' => array(), 'turism' => array(), 'plaza' => array(), 'autoplus' => array(), 'real' => array(), 'user' => array(), 'franchise' => array()); foreach ($tmp as $item) { switch ($item->prepareIdPermission()) { case 1: $permissions['banner'][] = 'add'; break; case 2: $permissions['banner'][] = 'edit'; break; case 3: $permissions['banner'][] = 'delete';
public function testCheckLoggedIn2() { $this->assertEquals(FALSE, fAuthorization::checkLoggedIn()); fAuthorization::setAuthLevels(array('user' => 20, 'admin' => 50)); fAuthorization::setUserAuthLevel('admin'); $this->assertEquals(TRUE, fAuthorization::checkLoggedIn()); }
/** * Attempt to login, and register through fAuthorization when successful. * * @throws sfNotFoundException When no user by provided username exists * @throws sfBadPasswordException When the given password fails to match * * @param string $username Username for attempted login * @param string $password Provided password to match * @return boolean True when successful */ public static function login($username, $password) { $login_attempt = sfCore::make('sfUser'); // will throw sfNotFoundException if not available $login_attempt->loadByUsername($username); if (!$login_attempt->matchPassword($password)) { throw new sfBadPasswordException(); return; } fAuthorization::setUserAuthLevel($login_attempt->getLevel()); fAuthorization::setUserToken($username); static::evaluateSession(); return true; }