ice framework documentation ice doc v1.10.1
Class Ice

Auth

    
namespace Ice;

/**
 * User authorization library. Handles user login and logout, as well as secure password hashing.
 *
 * @package     Ice/Auth
 * @category    Library
 * @author      Ice Team
 * @copyright   (c) 2014-2023 Ice Team
 * @license     http://iceframework.org/license
 *
 * 

 *  $options = ['hash_key' => 'secret key'];
 *  $this->di->auth = new \Ice\Auth($options);
 *
 *  $login = $this->auth->login($this->request->getPost('username'), $this->request->getPost('password'), $this->request->getPost('remember') ? TRUE : FALSE);
 *  if (!$login) {
 *      // Login failed, send back to form with error message
 *  } else {
 *      // Login successful
 *  }
 * 
* *

 *  if ($this->auth->loggedIn()) {
 *      // User is logged in, continue on
 *      $user = $this->auth->getUser();
 *      $username = $user->username;
 *  } else {
 *      // User isn't logged in, redirect to the login form.
 *  }
 * 
* *

 *  if ($this->auth->loggedIn('admin')) {
 *      // Admin privileges
 *  } else {
 *      // No access
 *  }
 * 
* *

 *  // Log out a user
 *  $this->auth->logout();
 * 
* * Seet usage: *

 *  {% if this.auth.loggedIn() %}
 *      {{ this.auth.getUser().username }}
 *  {% endif %}
 * 
*/ class Auth { }