From 2ca5a21ab4a5c03ea8c8a584ca832d01d8661691 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 9 Jul 2023 21:49:15 -0400 Subject: restart remote auth on cancel opcode --- src/remoteauth/remoteauthclient.cpp | 7 +++++++ src/remoteauth/remoteauthclient.hpp | 1 + 2 files changed, 8 insertions(+) (limited to 'src/remoteauth') diff --git a/src/remoteauth/remoteauthclient.cpp b/src/remoteauth/remoteauthclient.cpp index 7f41d71..467ea8b 100644 --- a/src/remoteauth/remoteauthclient.cpp +++ b/src/remoteauth/remoteauthclient.cpp @@ -58,6 +58,8 @@ void RemoteAuthClient::OnGatewayMessage(const std::string &str) { HandleGatewayPendingTicket(j); } else if (opcode == "pending_login") { HandleGatewayPendingLogin(j); + } else if (opcode == "cancel") { + HandleGatewayCancel(j); } } @@ -125,6 +127,11 @@ void RemoteAuthClient::HandleGatewayPendingLogin(const nlohmann::json &j) { m_signal_pending_login.emit(); } +void RemoteAuthClient::HandleGatewayCancel(const nlohmann::json &j) { + Stop(); + Start(); +} + void RemoteAuthClient::OnRemoteAuthLoginResponse(const std::optional &encrypted_token, DiscordError err) { if (!encrypted_token.has_value()) { m_log->error("Remote auth login failed: {}", static_cast(err)); diff --git a/src/remoteauth/remoteauthclient.hpp b/src/remoteauth/remoteauthclient.hpp index 36f224a..c2e00f3 100644 --- a/src/remoteauth/remoteauthclient.hpp +++ b/src/remoteauth/remoteauthclient.hpp @@ -23,6 +23,7 @@ private: void HandleGatewayPendingRemoteInit(const nlohmann::json &j); void HandleGatewayPendingTicket(const nlohmann::json &j); void HandleGatewayPendingLogin(const nlohmann::json &j); + void HandleGatewayCancel(const nlohmann::json &j); void OnRemoteAuthLoginResponse(const std::optional &encrypted_token, DiscordError err); -- cgit v1.2.3