src/Auth.php
public function login($usernameOrEmail = null, $password = null, $remember = false)
    {
        if (!$this->isLoggedIn()) {
            $user = $this->search($usernameOrEmail);

            if ($user) {
                if (Password::verify($password, $this->data()->Password)) {

                    // password is correct start a user session
                    $this->startSession();

                    if ($remember) {
                        $hash = Token::create(46);
                        $hashCheck = $this->db->select(
                            array('User_ID'),
                            $this->sessions,
                            null,
                            array(array('User_ID', '=', $this->data()->ID)),
                            array('LIMIT' => 1)
                        );

                        if (!$hashCheck->count()) {
                            $this->db->insert($this->sessions, array(
                                'User_ID' => $this->data()->ID,
                                'Token'   => $hash
                            ));
                        }
                        
                        Cookie::set($this->cookieName, $hash, $this->cookieExpiry);
                    }
                    return true;
                }
            }
        }
        return false;
    }
public function login($usernameOrEmail = null, $password = null, $remember = false)
    {
        if (!$this->isLoggedIn()) {
            $user = $this->search($usernameOrEmail);

            if ($user) {
                if (Password::verify($password, $this->data()->Password)) {

                    // password is correct start a user session
                    $this->startSession();

                    if ($remember) {
                        $hash = Token::create(46);
                        $hashCheck = $this->db->select(
                            array('User_ID'),
                            $this->sessions,
                            null,
                            array(array('User_ID', '=', $this->data()->ID)),
                            array('LIMIT' => 1)
                        );

                        if (!$hashCheck->count()) {
                            $this->db->insert($this->sessions, array(
                                'User_ID' => $this->data()->ID,
                                'Token'   => $hash
                            ));
                        }
                        
                        Cookie::set($this->cookieName, $hash, $this->cookieExpiry);
                    }
                    return true;
                }
            }
        }
        return false;
    }
public function login ( $ usernameOrEmail = null , $ password = null , $ remember = false ) { if ( ! $ this -> isLoggedIn ( ) ) { $ user = $ this -> search ( $ usernameOrEmail ) ; if ( $ user ) { if ( Password :: verify ( $ password , $ this -> data ( ) -> Password ) ) { // password is correct start a user session $ this -> startSession ( ) ; if ( $ remember ) { $ hash = Token :: create ( 46 ) ; $ hashCheck = $ this -> db -> select ( array ( 'User_ID' ) , $ this -> sessions , null , array ( array ( 'User_ID' , '=' , $ this -> data ( ) -> ID ) ) , array ( 'LIMIT' => 1 ) ) ; if ( ! $ hashCheck -> count ( ) ) { $ this -> db -> insert ( $ this -> sessions , array ( 'User_ID' => $ this -> data ( ) -> ID , 'Token' => $ hash ) ) ; } Cookie :: set ( $ this -> cookieName , $ hash , $ this -> cookieExpiry ) ; } return true ; } } } return false ; }
Log users in
Log users in