src/ChickenWire/Auth.php
public function isAuthenticated()
		{

			// Already authenticated?
			if ($this->_authenticated) return true;


			// Check session
			if (array_key_exists(self::$_sessionPrefix . $this->_name, $_SESSION)) {

				// Get credentials
				$cred = $_SESSION[self::$_sessionPrefix . $this->_name];
				
				// Init model
				$this->_initModel();

				// Find user
				$modelName = $this->_model;
				$user = $modelName::find("first", array(
							$this->_usernameField => $cred['username'],
							$this->_passwordField => $cred['password']
						));

				// Anything?
				if (is_null($user)) {
					return false;
				}

				// Set result
				$this->_result = new AuthResult(AuthResult::SUCCESS, $user);
				$this->_authenticated = true;
				$this->_user = $user;
				return true;

			}

			// Not authenticated.
			return false;

		}
public function isAuthenticated()
		{

			// Already authenticated?
			if ($this->_authenticated) return true;


			// Check session
			if (array_key_exists(self::$_sessionPrefix . $this->_name, $_SESSION)) {

				// Get credentials
				$cred = $_SESSION[self::$_sessionPrefix . $this->_name];
				
				// Init model
				$this->_initModel();

				// Find user
				$modelName = $this->_model;
				$user = $modelName::find("first", array(
							$this->_usernameField => $cred['username'],
							$this->_passwordField => $cred['password']
						));

				// Anything?
				if (is_null($user)) {
					return false;
				}

				// Set result
				$this->_result = new AuthResult(AuthResult::SUCCESS, $user);
				$this->_authenticated = true;
				$this->_user = $user;
				return true;

			}

			// Not authenticated.
			return false;

		}
public function isAuthenticated ( ) { // Already authenticated? if ( $ this -> _authenticated ) return true ; // Check session if ( array_key_exists ( self :: $ _sessionPrefix . $ this -> _name , $ _SESSION ) ) { // Get credentials $ cred = $ _SESSION [ self :: $ _sessionPrefix . $ this -> _name ] ; // Init model $ this -> _initModel ( ) ; // Find user $ modelName = $ this -> _model ; $ user = $ modelName :: find ( "first" , array ( $ this -> _usernameField => $ cred [ 'username' ] , $ this -> _passwordField => $ cred [ 'password' ] ) ) ; // Anything? if ( is_null ( $ user ) ) { return false ; } // Set result $ this -> _result = new AuthResult ( AuthResult :: SUCCESS , $ user ) ; $ this -> _authenticated = true ; $ this -> _user = $ user ; return true ; } // Not authenticated. return false ; }
Check if the current session is authenticated for this Auth instance
@return boolean True if authenticated, false when not authenticated.
Check if the current session is authenticated for this Auth instance