From 45b98b7879fed7d74a5e82e520b7975671da91e9 Mon Sep 17 00:00:00 2001 From: TheSainEyereg <37226226+TheSainEyereg@users.noreply.github.com> Date: Wed, 16 Mar 2022 23:44:48 +0300 Subject: [PATCH 1/2] Added 2FA support --- Applications/VK.app/Localizations/Dutch.lang | 2 ++ Applications/VK.app/Localizations/English.lang | 2 ++ Applications/VK.app/Localizations/Russian.lang | 2 ++ Applications/VK.app/Main.lua | 18 +++++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Applications/VK.app/Localizations/Dutch.lang b/Applications/VK.app/Localizations/Dutch.lang index 88730cb5..f85de603 100644 --- a/Applications/VK.app/Localizations/Dutch.lang +++ b/Applications/VK.app/Localizations/Dutch.lang @@ -8,6 +8,8 @@ username = "E-mail of telefoon nummer", password = "Wachtwoord", login = "Log in", + twoFactorEnabled = "2FA enthalten", + twoFactor = "2FA code", saveLogin = "Sla login informatie op:", loadCountConversations = "Het aantal geladen dialogen", diff --git a/Applications/VK.app/Localizations/English.lang b/Applications/VK.app/Localizations/English.lang index 46dfed2b..8f2fc0d4 100644 --- a/Applications/VK.app/Localizations/English.lang +++ b/Applications/VK.app/Localizations/English.lang @@ -8,6 +8,8 @@ username = "E-mail or phone number", password = "Password", login = "Enter", + twoFactorEnabled = "Use 2FA", + twoFactor = "2FA code", saveLogin = "Save login information:", loadCountConversations = "The number of loaded dialogues", diff --git a/Applications/VK.app/Localizations/Russian.lang b/Applications/VK.app/Localizations/Russian.lang index 7923e087..ef1ec6d2 100644 --- a/Applications/VK.app/Localizations/Russian.lang +++ b/Applications/VK.app/Localizations/Russian.lang @@ -8,6 +8,8 @@ username = "E-mail или номер телефона", password = "Пароль", login = "Войти", + twoFactorEnabled = "Использовать 2FA", + twoFactor = "Код 2FA", saveLogin = "Сохранять данные входа:", loadCountConversations = "Число загружаемых диалогов", diff --git a/Applications/VK.app/Main.lua b/Applications/VK.app/Main.lua index 2e74f6ff..af99de5f 100644 --- a/Applications/VK.app/Main.lua +++ b/Applications/VK.app/Main.lua @@ -120,7 +120,8 @@ local function request(url, postData, headers) return data else - GUI.alert("Failed to perform internet request: " .. tostring(reason)) + --GUI.alert("Failed to perform internet request: " .. tostring(reason)) + return nil, reason end end @@ -1668,6 +1669,9 @@ local function login() logo.height = logo.height + 1 local usernameInput = layout:addChild(GUI.input(1, 1, 36, 3, style.UIInputBackground, style.UIInputForeground, style.UIInputPlaceholder, style.UIInputBackground, style.UIInputFocusedForeground, config.username or "", localization.username)) local passwordInput = layout:addChild(GUI.input(1, 1, 36, 3, style.UIInputBackground, style.UIInputForeground, style.UIInputPlaceholder, style.UIInputBackground, style.UIInputFocusedForeground, config.password or "", localization.password, true, "•")) + local twoFactorSwitch = layout:addChild(GUI.switchAndLabel(1, 1, 36, 6, style.UISwitchActive, style.UISwitchPassive, style.UISwitchPipe, style.UIText, localization.twoFactorEnabled, false)) + local twoFactorInput = layout:addChild(GUI.input(1, 1, 36, 3, style.UIInputBackground, style.UIInputForeground, style.UIInputPlaceholder, style.UIInputBackground, style.UIInputFocusedForeground, config.twoFactor or "", localization.twoFactor)) + twoFactorInput.hidden = true local loginButton = layout:addChild(GUI.button(1, 1, 36, 3, style.UIButtonDefaultBackground, style.UIButtonDefaultForeground, style.UIButtonPressedBackground, style.UIButtonPressedForeground, localization.login)) loginButton.colors.disabled = { background = style.UIButtonDisabledBackground, @@ -1678,13 +1682,19 @@ local function login() loginusernameInput.hidden = true usernameInput.onInputFinished = function() - loginButton.disabled = #usernameInput.text == 0 or #passwordInput.text == 0 + loginButton.disabled = #usernameInput.text == 0 or #passwordInput.text == 0 or twoFactorSwitch.switch.state and #twoFactorInput.text == 0 workspace:draw() end passwordInput.onInputFinished = usernameInput.onInputFinished + twoFactorInput.onInputFinished = usernameInput.onInputFinished + + twoFactorSwitch.switch.onStateChanged = function() + twoFactorInput.hidden = not twoFactorSwitch.switch.state + usernameInput.onInputFinished() + end loginButton.onTouch = function() - local result, reason = request("https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username=" .. internet.encode(usernameInput.text) .. "&password=" .. internet.encode(passwordInput.text) .. "&v=" .. VKAPIVersion) + local result, reason = request("https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&2fa_supported=1&username=" .. internet.encode(usernameInput.text) .. "&password=" .. internet.encode(passwordInput.text) .. "&code=" .. twoFactorInput.text .. "&v=" .. VKAPIVersion) if result then if result.access_token then currentAccessToken = result.access_token @@ -1701,6 +1711,8 @@ local function login() end saveConfig() + else + GUI.alert("An error occurred while logging in: " .. reason) end end From ef1256e1119bdaafc13abc759a01d185e4d8d5bf Mon Sep 17 00:00:00 2001 From: TheSainEyereg <37226226+TheSainEyereg@users.noreply.github.com> Date: Thu, 17 Mar 2022 00:12:31 +0300 Subject: [PATCH 2/2] Shit style update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Лого говна обновил до актульного состояния 2. Иконки переделал чтобы да 3. Ну и цвета, сделал более адекватными под стиль VKUI --- Applications/VK.app/Icon.pic | Bin 318 -> 260 bytes Applications/VK.app/Icons/Comments.pic | Bin 89 -> 81 bytes Applications/VK.app/Icons/Likes.pic | Bin 79 -> 99 bytes Applications/VK.app/Icons/Reposts.pic | Bin 89 -> 89 bytes Applications/VK.app/Icons/Views.pic | Bin 97 -> 99 bytes Applications/VK.app/Styles/Bright.lua | 8 ++++---- Applications/VK.app/Styles/Dark.lua | 8 ++++---- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Applications/VK.app/Icon.pic b/Applications/VK.app/Icon.pic index 82c1974846b8987f6d2a9602b8367d8ba30bd16e..56648abf4ce7cbead5cdf8ecea08b234d77f396d 100644 GIT binary patch literal 260 zcmXw!K?=e^3`Kt?(~b*wUckEuf-5g2>aIs{>VRt(f)+vV@-I>|ZCnIi!p|ewZ+6>7 zQW=q0o&Z)>EwA4R6~a6?g5~1@VL3V`=FS6Vxce0B|ArP=vfNBOBAD7FGb+nzLP2DC yI5zA%4@C9{pN4u-U6Xpz+XKzIfC`b_Ja5mu9F=*t1O(=@TjU4CC_M}S literal 318 zcmXw!K?=e!5JmGRX_`enl_0qCN(zGRJc3CBJwZW1u*c|rE~1lUx(M@_{QvoL+8+-- zIQp3#=NT&o0L1Z9(IIerD)yYtDhQmv1qrb7IDS+^oL~CkNzCKs0H=jYxA_fRxezb53l*#aD!A3BXkpak@1Y$BWFfuYRGB7<_&;^wN Ks$T$QG6Ddra1QqX literal 89 zcmeZw_H<)oVPgEx!2W1a3nK&Le?}%o=0^+WK$$F$7A%1>nI0`z3}rGtTC@nvWMl*? Rm;_-mF)=?{I0Y)q2mo4^7%Tt) diff --git a/Applications/VK.app/Icons/Likes.pic b/Applications/VK.app/Icons/Likes.pic index 3fabfb077d63f55e54160483ea5f8df34ae5212d..196c6e1c2758233c0b061d93c56b41219cc5aebc 100644 GIT binary patch literal 99 zcmeZw_H^T5W@Px!!2W2_A_fRxezb4_n8nDz^k@-;3FJRo&;=D`ezX9hmXU$+(Sk`} RQ3epR1F8V1b_!IK2>=S76BPge literal 79 zcmeZw_H<)oVPgEx!1icS3nK&Le?}%orbi39piGuW3l~6{%#Ri=0y7zzm{=YymCr-%1Tz5M&JN`O literal 89 zcmeZw_H<)oVPgEx!2W1K7b64Xe?}%omPZShftXB;jLb}o%nD#(Mn=X*3#LI;Fg;q_ T02O6=w5Sg%%J^s@Oq2xx-USu& diff --git a/Applications/VK.app/Icons/Views.pic b/Applications/VK.app/Icons/Views.pic index 0c16fe1cc0fe292dd4029798bd8f58fb18743dcf..3844ff572cd3613991e7db0e893f9b9bde519d77 100644 GIT binary patch literal 99 zcmeZw_H^T5W@Px!!2W2#5(WrhdbDr>l*#yLK?j)0$iVPu!BQxb>Cu8ND3kfof<;g! PP;CR42_zmZgfW=`1@02_ literal 97 zcmeZw_H<)oVPgEx!0~87BO?Rje?}%omPd