From 527d4670d49bbb53b85918d5ed137374311f1f2f Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sun, 23 Dec 2018 10:06:06 -0600 Subject: [PATCH] Implemented two factor authentication for alternative tokens --- src/sessionmanager/wxUI.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/sessionmanager/wxUI.py b/src/sessionmanager/wxUI.py index 1da7330..009c887 100644 --- a/src/sessionmanager/wxUI.py +++ b/src/sessionmanager/wxUI.py @@ -1,23 +1,34 @@ # -*- coding: utf-8 -*- +import time import wx import widgetUtils +code = None +remember = True + def new_account_dialog(): return wx.MessageDialog(None, _(u"In order to continue, you need to configure your VK account before. Would you like to autorhise a new account now?"), _(u"Authorisation"), wx.YES_NO).ShowModal() def two_factor_auth(): + global code, remember + wx.CallAfter(get_code) + while code == None: + time.sleep(0.5) + return (code, remember) + +def get_code(): + global code, remember dlg = wx.TextEntryDialog(None, _(u"Please provide the authentication code you have received from VK."), _(u"Two factor authentication code")) response = dlg.ShowModal() if response == widgetUtils.OK: - result = dlg.GetValue() + code = dlg.GetValue() dlg.Destroy() - return (result, True) + dlg.Destroy() def two_factor_question(): return wx.MessageDialog(None, _(u"Do you have two factor authentication enabled in your account?"), _(u"Authentication method"), wx.YES_NO).ShowModal() - class newSessionDialog(widgetUtils.BaseDialog): def __init__(self): super(newSessionDialog, self).__init__(parent=None, id=wx.NewId(), title=_(u"Authorise VK"))