Skip to content
Snippets Groups Projects
Commit 048749b5 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Add Fallback auth and fix parsing of unauthorized, if no error is returned

parent dd455f49
No related branches found
No related tags found
No related merge requests found
......@@ -142,6 +142,8 @@ struct Terms
{};
struct Dummy
{};
struct Fallback
{};
}
struct Auth
{
......@@ -156,7 +158,8 @@ struct Auth
auth::MSISDN,
auth::OAuth2,
auth::Terms,
auth::Dummy>
auth::Dummy,
auth::Fallback>
content;
};
void
......
......@@ -84,7 +84,7 @@ from_string(const std::string &code)
void
from_json(const nlohmann::json &obj, Error &error)
{
error.errcode = from_string(obj.at("errcode").get<std::string>());
error.errcode = from_string(obj.value("errcode", ""));
error.error = obj.value("error", "");
if (obj.contains("session"))
......
......@@ -118,6 +118,7 @@ to_json(nlohmann::json &obj, const Auth &auth)
[&obj](const auth::OAuth2 &) { obj["type"] = auth_types::oauth2; },
[&obj](const auth::Terms &) { obj["type"] = auth_types::terms; },
[&obj](const auth::Dummy &) { obj["type"] = auth_types::dummy; },
[&obj](const auth::Fallback &) {},
},
auth.content);
}
......
......@@ -223,6 +223,10 @@ TEST(Requests, UserInteractiveAuth)
"type": "m.login.dummy",
"session": "<session ID>"
})"_json);
a.content = auth::Fallback{};
EXPECT_EQ(nlohmann::json(a), R"({
"session": "<session ID>"
})"_json);
a.content = auth::EmailIdentity{{
{"<identity server session id>",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment