mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-06 11:12:40 +01:00
Merge pull request #420 from TheSainEyereg/master
Двухфакторная аутентификация для ВК
This commit is contained in:
commit
9600a3b8f0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
username = "E-mail или номер телефона",
|
||||
password = "Пароль",
|
||||
login = "Войти",
|
||||
twoFactorEnabled = "Использовать 2FA",
|
||||
twoFactor = "Код 2FA",
|
||||
saveLogin = "Сохранять данные входа:",
|
||||
|
||||
loadCountConversations = "Число загружаемых диалогов",
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
UIBackground = 0xF0F0F0,
|
||||
UITitle = 0x3C3C3C,
|
||||
UIText = 0xB4B4B4,
|
||||
UISliderPrimary = 0x99DBFF,
|
||||
UISliderPrimary = 0x00B6FF,
|
||||
UISliderSecondary = 0xE1E1E1,
|
||||
UISliderPipe = 0xFFFFFF,
|
||||
UISliderValue = 0xA5A5A5,
|
||||
@ -58,13 +58,13 @@
|
||||
UIComboBoxArrowBackground = 0xD2D2D2,
|
||||
UIComboBoxArrowForeground = 0x969696,
|
||||
UIProgressIndicatorPassive = 0xD2D2D2,
|
||||
UIProgressIndicatorPrimary = 0x33B6FF,
|
||||
UIProgressIndicatorSecondary = 0x99DBFF,
|
||||
UIProgressIndicatorPrimary = 0x00B6FF,
|
||||
UIProgressIndicatorSecondary = 0x006DFF,
|
||||
UIInputBackground = 0xE1E1E1,
|
||||
UIInputForeground = 0x787878,
|
||||
UIInputPlaceholder = 0xA5A5A5,
|
||||
UIInputFocusedForeground = 0x787878,
|
||||
UISwitchActive = 0x99DBFF,
|
||||
UISwitchActive = 0x00B6FF,
|
||||
UISwitchPassive = 0xD2D2D2,
|
||||
UISwitchPipe = 0xFFFFFF,
|
||||
UIButtonDefaultBackground = 0xD2D2D2,
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
UIBackground = 0x2D2D2D,
|
||||
UITitle = 0xE1E1E1,
|
||||
UIText = 0x5A5A5A,
|
||||
UISliderPrimary = 0xCC92FF,
|
||||
UISliderPrimary = 0x006DFF,
|
||||
UISliderSecondary = 0x2D2D2D,
|
||||
UISliderPipe = 0xFFFFFF,
|
||||
UISliderValue = 0x696969,
|
||||
@ -58,13 +58,13 @@
|
||||
UIComboBoxArrowBackground = 0x5A5A5A,
|
||||
UIComboBoxArrowForeground = 0xE1E1E1,
|
||||
UIProgressIndicatorPassive = 0x1E1E1E,
|
||||
UIProgressIndicatorPrimary = 0x662480,
|
||||
UIProgressIndicatorSecondary = 0xCC92FF,
|
||||
UIProgressIndicatorPrimary = 0x006DFF,
|
||||
UIProgressIndicatorSecondary = 0x00B6FF,
|
||||
UIInputBackground = 0x3C3C3C,
|
||||
UIInputForeground = 0x878787,
|
||||
UIInputPlaceholder = 0x5A5A5A,
|
||||
UIInputFocusedForeground = 0xA5A5A5,
|
||||
UISwitchActive = 0x664980,
|
||||
UISwitchActive = 0x00B6FF,
|
||||
UISwitchPassive = 0xD2D2D2,
|
||||
UISwitchPipe = 0xFFFFFF,
|
||||
UIButtonDefaultBackground = 0x4B4B4B,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user