diff --git a/include/jwt/impl/jwt.ipp b/include/jwt/impl/jwt.ipp index 7e9beb0..88b3d67 100644 --- a/include/jwt/impl/jwt.ipp +++ b/include/jwt/impl/jwt.ipp @@ -285,10 +285,8 @@ jwt_object::three_parts(const string_view enc_str) result[1] = string_view{&enc_str[fpos + 1], spos - fpos - 1}; - size_t tpos = enc_str.find_first_of('.', spos + 1); - - if (tpos != string_view::npos) { - result[2] = string_view{&enc_str[tpos + 1], tpos - spos - 1}; + if (spos != enc_str.length()) { + result[2] = string_view{&enc_str[spos + 1], enc_str.length() - spos}; } return result; @@ -314,7 +312,7 @@ jwt_object jwt_decode(const string_view encoded_str, const string_view key, bool //length of the encoded header and payload only. //Addition of '1' to account for the '.' character. auto l = parts[0].length() + 1 + parts[1].length(); - jsign.verify(jobj.header(), encoded_str.substr(0, l), parts[2]); + auto res = jsign.verify(jobj.header(), encoded_str.substr(0, l), parts[2]); return jobj; } diff --git a/include/jwt/test/test_jwt_object b/include/jwt/test/test_jwt_object index db08c41..696b3a1 100755 Binary files a/include/jwt/test/test_jwt_object and b/include/jwt/test/test_jwt_object differ diff --git a/include/jwt/test/test_jwt_object.cc b/include/jwt/test/test_jwt_object.cc index 00e9ecd..7612bfb 100644 --- a/include/jwt/test/test_jwt_object.cc +++ b/include/jwt/test/test_jwt_object.cc @@ -41,7 +41,7 @@ void basic_jwt_object_test() obj3.secret("secret"); obj3.header().algo("hs256"); - std::cout << obj3.signature() << std::endl; + auto dec_obj = jwt::jwt_decode(obj3.signature(), "secret"); } int main() {