Change the user password.

        Parameters
        ----------
        auth_secret: str
            The authentication secret which will be used for user authentication.
        old_password: str
            The old password before the change.
        new_password: str
            The new password after the change.

        Returns
        -------
        bool
            True if the password is successfully changed, False otherwise.
        result
            A dict containing the new authentication secret with the key AUTH_KEY
            if the password is successfully changed, a dict containing the error
            string with the key ERROR_KEY otherwise.

        Note
        ----
        Possible error strings are listed as below:

        -  ERROR_NEW_PASSWORD_NO_CHANGE
        -  ERROR_NOT_LOGGED_IN
        -  ERROR_INCORRECT_OLD_PASSWORD
        -  ERROR_WEAK_PASSWORD

def change_password(self, auth_secret, old_password, new_password):
        """Change the user password.

        Parameters
        ----------
        auth_secret: str
            The authentication secret which will be used for user authentication.
        old_password: str
            The old password before the change.
        new_password: str
            The new password after the change.

        Returns
        -------
        bool
            True if the password is successfully changed, False otherwise.
        result
            A dict containing the new authentication secret with the key AUTH_KEY
            if the password is successfully changed, a dict containing the error
            string with the key ERROR_KEY otherwise.

        Note
        ----
        Possible error strings are listed as below:

        -  ERROR_NEW_PASSWORD_NO_CHANGE
        -  ERROR_NOT_LOGGED_IN
        -  ERROR_INCORRECT_OLD_PASSWORD
        -  ERROR_WEAK_PASSWORD
        """
        result = {pytwis_constants.ERROR_KEY: None}

        if old_password == new_password:
            result[pytwis_constants.ERROR_KEY] = \
                pytwis_constants.ERROR_NEW_PASSWORD_NO_CHANGE
            return (False, result)

        # Check if the user is logged in.
        loggedin, userid = self._is_loggedin(auth_secret)
        if not loggedin:
            result[pytwis_constants.ERROR_KEY] = pytwis_constants.ERROR_NOT_LOGGED_IN
            return (False, result)

        # Check if the old password matches.
        userid_profile_key = pytwis_constants.USER_PROFILE_KEY_FORMAT.format(userid)
        stored_password_hash = self._rc.hget(userid_profile_key,
                                             pytwis_constants.PASSWORD_HASH_KEY)
        if not check_password_hash(stored_password_hash, old_password):
            result[pytwis_constants.ERROR_KEY] = \
                pytwis_constants.ERROR_INCORRECT_OLD_PASSWORD
            return (False, result)

        # Check the password.
        if not Pytwis._check_password(new_password):
            result[pytwis_constants.ERROR_KEY] = pytwis_constants.ERROR_WEAK_PASSWORD
            return (False, result)

        # Generate the new authentication secret.
        new_auth_secret = secrets.token_hex()

        # Generate the new password hash.
        # The format of the new password hash looks like "method$salt$hash".
        new_password_hash = generate_password_hash(new_password,
                                                   method=\
                                                   pytwis_constants.PASSWORD_HASH_METHOD)

        # Replace the old password hash by the new one and the old authentication secret
        # by the new one.
        with self._rc.pipeline() as pipe:
            pipe.multi()
            pipe.hset(userid_profile_key,
                      pytwis_constants.PASSWORD_HASH_KEY,
                      new_password_hash)
            pipe.hset(userid_profile_key, pytwis_constants.AUTH_KEY, new_auth_secret)
            pipe.hset(pytwis_constants.AUTHS_KEY, new_auth_secret, userid)
            pipe.hdel(pytwis_constants.AUTHS_KEY, auth_secret)
            pipe.execute()

        result[pytwis_constants.AUTH_KEY] = new_auth_secret
        return (True, result)