'Check that a password reset token is correct for a given user.'

def check_token(self, user, token):

    try:
        (ts_b36, hash) = token.split('-')
    except ValueError:
        return False
    try:
        ts = base36_to_int(ts_b36)
    except ValueError:
        return False
    if (not constant_time_compare(self._make_token_with_timestamp(user, ts), token)):
        if (not constant_time_compare(self._make_token_with_timestamp_old(user, ts), token)):
            return False
    if ((self._num_days(self._today()) - ts) > settings.PASSWORD_RESET_TIMEOUT_DAYS):
        return False
    return True
