CakePHPのAuthComponentの履歴

cake/libs/controller/components/auth.php

$this->Auth->login();

    function login($data = null) {
        $this->__setDefaults();
        $this->_loggedIn = false;

        if (empty($data)) {
            $data = $this->data;
        }

        if ($user = $this->identify($data)) {
            $this->Session->write($this->sessionKey, $user);
            $this->_loggedIn = true;
        }
        return $this->_loggedIn;
    }

identify

    function identify($user = null, $conditions = null) {
        if ($conditions === false) {
            $conditions = null;
        } elseif (is_array($conditions)) {
            $conditions = array_merge((array)$this->userScope, $conditions);
        } else {
            $conditions = $this->userScope;
        }
        $model =& $this->getModel();
        if (empty($user)) {
            $user = $this->user();
            if (empty($user)) {
                return null;  
            }
        } elseif (is_object($user) && is_a($user, 'Model')) {
            if (!$user->exists()) {
                return null;
            }
            $user = $user->read();
            $user = $user[$model->alias];
        } elseif (is_array($user) && isset($user[$model->alias])) {
            $user = $user[$model->alias];
        }

        if (is_array($user) && (isset($user[$this->fields['username']]) || isset($user[$model->alias . '.' . $this->fields['username']]))) {
            if (isset($user[$this->fields['username']]) && !empty($user[$this->fields['username']])  && !empty($user[$this->fields['password']])) {
                if (trim($user[$this->fields['username']]) == '=' || trim($user[$this->fields['password']]) == '=') {
                    return false;
                }
                $find = array(
                    $model->alias.'.'.$this->fields['username'] => $user[$this->fields['username']],
                    $model->alias.'.'.$this->fields['password'] => $user[$this->fields['password']]
                );
            } elseif (isset($user[$model->alias . '.' . $this->fields['username']]) && !empty($user[$model->alias . '.' . $this->fields['username']])) {
                if (trim($user[$model->alias . '.' . $this->fields['username']]) == '=' || trim($user[$model->alias . '.' . $this->fields['password']]) == '=') {
                    return false;
                }
                $find = array(
                    $model->alias.'.'.$this->fields['username'] => $user[$model->alias . '.' . $this->fields['username']],
                    $model->alias.'.'.$this->fields['password'] => $user[$model->alias . '.' . $this->fields['password']]
                );
            } else {
                return false;
            }
            $data = $model->find('first', array(
                'conditions' => array_merge($find, $conditions),
                'recursive' => 0
            ));
            if (empty($data) || empty($data[$model->alias])) {
                return null;
            }
        } elseif (!empty($user) && is_string($user)) {
            $data = $model->find('first', array(
                'conditions' => array_merge(array($model->escapeField() => $user), $conditions),
            ));
            if (empty($data) || empty($data[$model->alias])) {
                return null;
            }
        }

        if (!empty($data)) {
            if (!empty($data[$model->alias][$this->fields['password']])) {
                unset($data[$model->alias][$this->fields['password']]);
            }
            return $data[$model->alias];
        }
        return null;
    }

$this->Auth->user();

    function user($key = null) {
        $this->__setDefaults();
        if (!$this->Session->check($this->sessionKey)) {
            return null;
        }

        if ($key == null) {
            $model =& $this->getModel();
            return array($model->alias => $this->Session->read($this->sessionKey));
        } else {
            $user = $this->Session->read($this->sessionKey);
            if (isset($user[$key])) {
                return $user[$key];
            }
            return null;
        }
    }