diff options
author | George Hazan <george.hazan@gmail.com> | 2024-05-06 13:54:22 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-05-06 13:54:22 +0300 |
commit | dd0d066e1f2223e96d8555f567763a75c73e8b14 (patch) | |
tree | 9ee60ee8c1b9438e6e271b4b85a2f73499c90c26 /protocols/Discord | |
parent | 4588d6a0fb7983b74d656779864aaa0a39465546 (diff) |
fixes #4405 (Discord: логин по номеру телефона)
Diffstat (limited to 'protocols/Discord')
-rw-r--r-- | protocols/Discord/res/discord.rc | 4 | ||||
-rw-r--r-- | protocols/Discord/src/http.cpp | 12 | ||||
-rw-r--r-- | protocols/Discord/src/options.cpp | 20 | ||||
-rw-r--r-- | protocols/Discord/src/server.cpp | 10 |
4 files changed, 31 insertions, 15 deletions
diff --git a/protocols/Discord/res/discord.rc b/protocols/Discord/res/discord.rc index b272538e49..283582c0da 100644 --- a/protocols/Discord/res/discord.rc +++ b/protocols/Discord/res/discord.rc @@ -72,7 +72,7 @@ EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "User details",IDC_STATIC,7,7,291,46
- LTEXT "E-mail:",IDC_STATIC,17,20,61,8,0,WS_EX_RIGHT
+ LTEXT "E-mail or phone:",IDC_STATIC,17,20,61,8,0,WS_EX_RIGHT
EDITTEXT IDC_USERNAME,84,18,123,13,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,17,36,61,8,0,WS_EX_RIGHT
EDITTEXT IDC_PASSWORD,84,34,123,13,ES_PASSWORD | ES_AUTOHSCROLL
@@ -95,7 +95,7 @@ EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "User details",IDC_STATIC,7,7,178,46
- LTEXT "E-mail:",IDC_STATIC,17,20,69,8,0,WS_EX_RIGHT
+ LTEXT "E-mail or phone:",IDC_STATIC,17,20,69,8,0,WS_EX_RIGHT
EDITTEXT IDC_USERNAME,92,18,86,13,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,17,36,69,8,0,WS_EX_RIGHT
EDITTEXT IDC_PASSWORD,92,34,86,13,ES_PASSWORD | ES_AUTOHSCROLL
diff --git a/protocols/Discord/src/http.cpp b/protocols/Discord/src/http.cpp index b8e71aa09a..b349eac36b 100644 --- a/protocols/Discord/src/http.cpp +++ b/protocols/Discord/src/http.cpp @@ -107,7 +107,8 @@ void CDiscordProto::ServerThread(void*) if (m_szAccessToken != nullptr)
RetrieveMyInfo(); // try to receive a response from server
else {
- if (mir_wstrlen(m_wszEmail) == 0) {
+ CMStringW wszEmail(m_wszEmail);
+ if (wszEmail.IsEmpty()) {
ConnectionFailed(LOGINERR_BADUSERID);
return;
}
@@ -118,7 +119,14 @@ void CDiscordProto::ServerThread(void*) return;
}
- JSONNode root; root << WCHAR_PARAM("email", m_wszEmail) << WCHAR_PARAM("password", wszPassword);
+ JSONNode root; root << WCHAR_PARAM("password", wszPassword);
+ if (wszEmail.Find('@') == -1) {
+ if (wszEmail[0] != '+')
+ wszEmail.Insert(0, L"+");
+ root << WCHAR_PARAM("login", wszEmail) ;
+ }
+ else root << WCHAR_PARAM("email", wszEmail);
+
Push(new AsyncHttpRequest(this, REQUEST_POST, "/auth/login", &CDiscordProto::OnReceiveToken, &root));
}
diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp index 3262b37671..dc1c6eafa8 100644 --- a/protocols/Discord/src/options.cpp +++ b/protocols/Discord/src/options.cpp @@ -81,7 +81,15 @@ public: void onClick_Logout(CCtrlButton *)
{
- m_proto->Push(new AsyncHttpRequest(m_proto, REQUEST_POST, "/auth/logout", &CDiscordProto::OnReceiveLogout));
+ auto *pReq = new AsyncHttpRequest(m_proto, REQUEST_POST, "/auth/logout", &CDiscordProto::OnReceiveLogout);
+ pReq->pUserInfo = this;
+ m_proto->Push(pReq);
+ }
+
+ void onLogout()
+ {
+ m_edUserName.Enable();
+ m_edPassword.Enable();
}
void onChange_GroupChats(CCtrlCheck*)
@@ -92,6 +100,16 @@ public: }
};
+void CDiscordProto::OnReceiveLogout(MHttpResponse *, AsyncHttpRequest *pReq)
+{
+ delSetting(DB_KEY_TOKEN);
+ m_szAccessToken = 0;
+ ShutdownSession();
+
+ auto *pDlg = (CDiscardAccountOptions *)pReq->pUserInfo;
+ pDlg->onLogout();
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
MWindow CDiscordProto::OnCreateAccMgrUI(MWindow hwndParent)
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 54d41ede49..728a56da7d 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -165,7 +165,6 @@ void CDiscordProto::OnReceiveMyInfo(MHttpResponse *pReply, AsyncHttpRequest*) setByte(0, DB_KEY_MFA, data["mfa_enabled"].as_bool());
setDword(0, DB_KEY_DISCR, _wtoi(data["discriminator"].as_mstring()));
setWString(0, DB_KEY_NICK, data["username"].as_mstring());
- m_wszEmail = data["email"].as_mstring();
m_ownId = id;
m_szCookie = pReply->GetCookies();
@@ -217,15 +216,6 @@ void CDiscordProto::OnReceiveCreateChannel(MHttpResponse *pReply, AsyncHttpReque /////////////////////////////////////////////////////////////////////////////////////////
-void CDiscordProto::OnReceiveLogout(MHttpResponse *, AsyncHttpRequest *)
-{
- delSetting(DB_KEY_TOKEN);
- m_szAccessToken = 0;
- ShutdownSession();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
void CDiscordProto::OnReceiveMessageAck(MHttpResponse *pReply, AsyncHttpRequest*)
{
JsonReply root(pReply);
|