<?php include "nxauth.php"; if (NXAuth::user()) { header("Location: {$base_url}"); exit; } NXAuth::login($base_url);
/** * Get a model containing data for the current user * * This method is singletone'd so calling it multiple times is no performace hit * * @return NXUser instance or null if not authenticated */ public static function user() { if (self::is_authenticated()) { if (self::$user == null) { self::$user = new NXUser(); } return self::$user; } else { return null; } }
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>NXAuth Test</title> </head> <body> <h1>NXAuth Test</h1> <?php if ($user) { ?> <form action="logout.php" method="get"> <button type="submit">Logout</button> </form> <h2>User</h2> <?php dump(NXAuth::user()); ?> <h2>Functions</h2> <?php foreach ($functions as $f => $args) { ?> <?php if ($args === null) { $args = array(); } ?> <h3><?php echo $f; ?> </h3> <?php