summaryrefslogtreecommitdiff
path: root/protocols/Discord/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-15 12:53:52 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-15 12:53:52 +0300
commit17944741957b032d6ab360d78ab4fc26a0467706 (patch)
tree9744d465c83e56cfab8439f3e414ed89b108794b /protocols/Discord/src
parentad952090c27086537f8c407a228e8d609a22b0fc (diff)
fixes #4120 (Discord: второй фактор запрашивается при каждом выходе в онлайн)
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r--protocols/Discord/src/gateway.cpp13
-rw-r--r--protocols/Discord/src/options.cpp16
-rw-r--r--protocols/Discord/src/resource.h4
-rw-r--r--protocols/Discord/src/server.cpp8
4 files changed, 29 insertions, 12 deletions
diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp
index 30a32bb5f6..8367462159 100644
--- a/protocols/Discord/src/gateway.cpp
+++ b/protocols/Discord/src/gateway.cpp
@@ -305,17 +305,10 @@ void CDiscordProto::GatewaySendResume()
/////////////////////////////////////////////////////////////////////////////////////////
-void CDiscordProto::OnReceiveLogout(MHttpResponse *, AsyncHttpRequest *)
-{
- delSetting(DB_KEY_TOKEN);
-}
-
bool CDiscordProto::GatewaySendStatus(int iStatus, const wchar_t *pwszStatusText)
{
- if (iStatus == ID_STATUS_OFFLINE) {
- Push(new AsyncHttpRequest(this, REQUEST_POST, "/auth/logout", &CDiscordProto::OnReceiveLogout));
- return true;
- }
+ // if (iStatus == ID_STATUS_OFFLINE)
+ // return true;
const char *pszStatus;
switch (iStatus) {
@@ -326,6 +319,8 @@ bool CDiscordProto::GatewaySendStatus(int iStatus, const wchar_t *pwszStatusText
pszStatus = "dnd"; break;
case ID_STATUS_INVISIBLE:
pszStatus = "invisible"; break;
+ case ID_STATUS_OFFLINE:
+ pszStatus = "offline"; break;
default:
pszStatus = "online"; break;
}
diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp
index dc4a6d60b5..11c73c64d0 100644
--- a/protocols/Discord/src/options.cpp
+++ b/protocols/Discord/src/options.cpp
@@ -21,13 +21,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class CDiscardAccountOptions : public CDiscordDlgBase
{
- CCtrlCheck chkUseChats, chkHideChats, chkUseGroups, chkDeleteMsgs;
- CCtrlEdit m_edGroup, m_edUserName, m_edPassword;
ptrW m_wszOldGroup;
+ CCtrlEdit m_edGroup, m_edUserName, m_edPassword;
+ CCtrlCheck chkUseChats, chkHideChats, chkUseGroups, chkDeleteMsgs;
+ CCtrlButton btnLogout;
public:
CDiscardAccountOptions(CDiscordProto *ppro, int iDlgID, bool bFullDlg) :
CDiscordDlgBase(ppro, iDlgID),
+ btnLogout(this, IDC_LOGOUT),
m_edGroup(this, IDC_GROUP),
m_edUserName(this, IDC_USERNAME),
m_edPassword(this, IDC_PASSWORD),
@@ -37,6 +39,8 @@ public:
chkDeleteMsgs(this, IDC_DELETE_MSGS),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
+ btnLogout.OnClick = Callback(this, &CDiscardAccountOptions::onClick_Logout);
+
CreateLink(m_edGroup, ppro->m_wszDefaultGroup);
CreateLink(m_edUserName, ppro->m_wszEmail);
if (bFullDlg) {
@@ -51,6 +55,9 @@ public:
bool OnInitDialog() override
{
+ if (m_proto->getMStringA(DB_KEY_TOKEN).IsEmpty())
+ btnLogout.Disable();
+
ptrW buf(m_proto->getWStringA(DB_KEY_PASSWORD));
if (buf)
m_edPassword.SetText(buf);
@@ -67,6 +74,11 @@ public:
return true;
}
+ void onClick_Logout(CCtrlButton *)
+ {
+ m_proto->Push(new AsyncHttpRequest(m_proto, REQUEST_POST, "/auth/logout", &CDiscordProto::OnReceiveLogout));
+ }
+
void onChange_GroupChats(CCtrlCheck*)
{
bool bEnabled = chkUseChats.GetState();
diff --git a/protocols/Discord/src/resource.h b/protocols/Discord/src/resource.h
index dc1c9706f1..00f55d2886 100644
--- a/protocols/Discord/src/resource.h
+++ b/protocols/Discord/src/resource.h
@@ -21,6 +21,8 @@
#define IDC_DELETE_MSGS 1009
#define IDC_ANOTHER 1009
#define IDC_LABEL 1010
+#define IDC_BUTTON1 1011
+#define IDC_LOGOUT 1011
// Next default values for new objects
//
@@ -28,7 +30,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1011
+#define _APS_NEXT_CONTROL_VALUE 1012
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index 7bc887edef..d06e307539 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -214,6 +214,14 @@ void CDiscordProto::OnReceiveCreateChannel(MHttpResponse *pReply, AsyncHttpReque
/////////////////////////////////////////////////////////////////////////////////////////
+void CDiscordProto::OnReceiveLogout(MHttpResponse *, AsyncHttpRequest *)
+{
+ delSetting(DB_KEY_TOKEN);
+ ShutdownSession();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CDiscordProto::OnReceiveMessageAck(MHttpResponse *pReply, AsyncHttpRequest*)
{
JsonReply root(pReply);