Example #1
0
 public function doSignOut()
 {
     $answer = new StdClass();
     $answer->success = User::signOut();
     header('Location: /');
     return $answer;
 }
Example #2
0
// authenticated
$handler = new AuthenticationHandler();
$user->setAuthenticationHandler($handler);
echo "authenticate as john\n";
$user->authenticate('john', 'xxx');
echo "isAuthenticated?\n";
Debug::dump($user->isAuthenticated());
echo "getRoles()\n";
Debug::dump($user->getRoles());
echo "is admin?\n";
Debug::dump($user->isInRole('admin'));
echo "is guest?\n";
Debug::dump($user->isInRole('guest'));
// authorization
try {
    echo "authorize without handler\n";
    Debug::dump($user->isAllowed('delete_file'));
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
$handler = new AuthorizationHandler();
$user->setAuthorizationHandler($handler);
echo "isAllowed('delete_file')?\n";
Debug::dump($user->isAllowed('delete_file'));
echo "isAllowed('sleep_with_jany')?\n";
Debug::dump($user->isAllowed('sleep_with_jany'));
// sign out
echo "signing out...\n";
$user->signOut(FALSE);
echo "isAllowed('delete_file')?\n";
Debug::dump($user->isAllowed('delete_file'));
Example #3
0
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), ' #', $e->getCode(), "\n\n";
}
try {
    echo "authenticate as john#2\n";
    $user->authenticate('john', 'xxx');
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), ' #', $e->getCode(), "\n\n";
}
echo "isAuthenticated?\n";
Debug::dump($user->isAuthenticated());
echo "getIdentity\n";
Debug::dump($user->getIdentity());
// sign out
echo "signing out...\n";
$user->signOut(FALSE);
echo "isAuthenticated?\n";
Debug::dump($user->isAuthenticated());
echo "getIdentity\n";
Debug::dump($user->getIdentity());
echo "signing out and clearing identity...\n";
$user->signOut(TRUE);
echo "isAuthenticated?\n";
Debug::dump($user->isAuthenticated());
echo "getIdentity\n";
Debug::dump($user->getIdentity());
// namespace
echo "authenticate as john#2?\n";
$user->authenticate('john', 'xxx');
echo "isAuthenticated?\n";
Debug::dump($user->isAuthenticated());