Log into a user.

        Parameters
        ----------
        username: str
            The username.
        password: str
            The password.

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

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

        -  ERROR_USERNAME_NOT_EXIST_FORMAT.format(username)
        -  ERROR_INCORRECT_PASSWORD

def login(self, username, password):
        """Log into a user.

        Parameters
        ----------
        username: str
            The username.
        password: str
            The password.

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

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

        -  ERROR_USERNAME_NOT_EXIST_FORMAT.format(username)
        -  ERROR_INCORRECT_PASSWORD
        """
        result = {pytwis_constants.ERROR_KEY: None}

        # Get the user-id based on the username.
        userid = self._rc.hget(pytwis_constants.USERS_KEY, username)
        if userid is None:
            result[pytwis_constants.ERROR_KEY] = \
                pytwis_constants.ERROR_USERNAME_NOT_EXIST_FORMAT.format(username)
            return (False, result)

        # Compare the input password hash with the stored one. If it matches,
        # return the authentication secret.
        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 check_password_hash(stored_password_hash, password):
            result[pytwis_constants.AUTH_KEY] = \
                self._rc.hget(userid_profile_key, pytwis_constants.AUTH_KEY)
            return (True, result)

        result[pytwis_constants.ERROR_KEY] = pytwis_constants.ERROR_INCORRECT_PASSWORD
        return (False, result)