public function activateUser($key)
    {

        // Get tokendate from db
        $tokenhandler = new ActivationToken($this->db);
        $tokenhandler->setSelectorTokenString($key);

        // Store the current to extracted from selector:token string ($key)
        $token_from_key = $tokenhandler->getToken();

        // Load the tokendata by using the selector from selector:token string ($key)
        $tokenhandler->loadTokenData();

        // Get user id
        $id_user = $tokenhandler->getUserId();

        // No user id means the activation must fail
        if (empty($id_user)) {
            return false;
        }

        // Get the token loaded from db via selector from selector:token string ($key)
        $token_from_db = $tokenhandler->getToken();

        // Matching hashes?
        if (!hash_equals($token_from_key, $token_from_db)) {
            return false;
        }

        // Activate user
        $this->db->qb([
            'table' => 'core_users',
            'method' => 'UPDATE',
            'fields' => 'state',
            'filter' => 'id_user=:id_user',
            'params' => [
                ':state' => 0,
                ':id_user' => $id_user
            ]
        ], true);

        // and delete the token of this user
        $tokenhandler->deleteActivationTokenByUserId($id_user);

        // And finally return user id
        return $id_user;
    }
public function activateUser($key)
    {

        // Get tokendate from db
        $tokenhandler = new ActivationToken($this->db);
        $tokenhandler->setSelectorTokenString($key);

        // Store the current to extracted from selector:token string ($key)
        $token_from_key = $tokenhandler->getToken();

        // Load the tokendata by using the selector from selector:token string ($key)
        $tokenhandler->loadTokenData();

        // Get user id
        $id_user = $tokenhandler->getUserId();

        // No user id means the activation must fail
        if (empty($id_user)) {
            return false;
        }

        // Get the token loaded from db via selector from selector:token string ($key)
        $token_from_db = $tokenhandler->getToken();

        // Matching hashes?
        if (!hash_equals($token_from_key, $token_from_db)) {
            return false;
        }

        // Activate user
        $this->db->qb([
            'table' => 'core_users',
            'method' => 'UPDATE',
            'fields' => 'state',
            'filter' => 'id_user=:id_user',
            'params' => [
                ':state' => 0,
                ':id_user' => $id_user
            ]
        ], true);

        // and delete the token of this user
        $tokenhandler->deleteActivationTokenByUserId($id_user);

        // And finally return user id
        return $id_user;
    }
public function activateUser ( $ key ) { // Get tokendate from db $ tokenhandler = new ActivationToken ( $ this -> db ) ; $ tokenhandler -> setSelectorTokenString ( $ key ) ; // Store the current to extracted from selector:token string ($key) $ token_from_key = $ tokenhandler -> getToken ( ) ; // Load the tokendata by using the selector from selector:token string ($key) $ tokenhandler -> loadTokenData ( ) ; // Get user id $ id_user = $ tokenhandler -> getUserId ( ) ; // No user id means the activation must fail if ( empty ( $ id_user ) ) { return false ; } // Get the token loaded from db via selector from selector:token string ($key) $ token_from_db = $ tokenhandler -> getToken ( ) ; // Matching hashes? if ( ! hash_equals ( $ token_from_key , $ token_from_db ) ) { return false ; } // Activate user $ this -> db -> qb ( [ 'table' => 'core_users' , 'method' => 'UPDATE' , 'fields' => 'state' , 'filter' => 'id_user=:id_user' , 'params' => [ ':state' => 0 , ':id_user' => $ id_user ] ] , true ) ; // and delete the token of this user $ tokenhandler -> deleteActivationTokenByUserId ( $ id_user ) ; // And finally return user id return $ id_user ; }
Actives user by using a key

@param string $key
Key to use for activation
Actives user by using a key