Changeset 1186:beb5a473fd54


Ignore:
Timestamp:
04/30/25 15:05:57 (8 hours ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Tags:
tip
Message:

SimBrief MFA login is supported

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r1167 r1186  
    916916"the password is stored as text, and anybody who can access "
    917917"your files will be able to read it."
     918
     919msgid "simbrief_mfa_code_title"
     920msgstr "Enter MFA code"
     921
     922msgid "simbrief_mfa_code_needed"
     923msgstr ""
     924"An MFA code is sent by Navigraph to your\n"
     925"e-mail address to complete the login.\n"
     926"Check your e-mail for the code and enter it below."
     927
     928msgid "simbrief_mfa_code"
     929msgstr "MFA code:"
     930
     931msgid "simbrief_mfa_code_tooltip"
     932msgstr "Enter the code received by e-mail."
    918933
    919934msgid "simbrief_extra_fuel"
  • locale/hu/mlx.po

    r1167 r1186  
    915915"mindig újból beírnod. Vedd azonban figyelembe, hogy a jelszót szövegként "
    916916"tároljuk, ezért bárki elolvashatja, aki hozzáfér a fájljaidhoz."
     917
     918msgid "simbrief_mfa_code_title"
     919msgstr "2FA kód bírása"
     920
     921msgid "simbrief_mfa_code_needed"
     922msgstr ""
     923"A Navigraph egy, a kétlépcsős azonosításhoz szükséges\n"
     924"kódot küldött az e-mail címedre a belépéshez.\n"
     925"Keresd meg a kódot a leveleid között és írd be."
     926
     927msgid "simbrief_mfa_code"
     928msgstr "2FA kód:"
     929
     930msgid "simbrief_mfa_code_tooltip"
     931msgstr "Írd be az e-mailben kapott kódot."
    917932
    918933msgid "simbrief_extra_fuel"
  • src/mlx/gui/cef.py

    r1111 r1186  
    5757SIMBRIEF_RESULT_ERROR_LOGIN_FAILED = 13
    5858
     59#-----------------------------------------------------------------------------
     60
     61class SimBriefMFACodeDialog(Gtk.Dialog):
     62    """A dialog window to ask for the SimBrief (Navigraph) MFA code."""
     63    def __init__(self, gui):
     64        """Construct the dialog."""
     65        super(SimBriefMFACodeDialog, self).__init__(WINDOW_TITLE_BASE + " - " +
     66                                                    xstr("simbrief_mfa_code_title"),
     67                                                    gui.mainWindow,
     68                                                    Gtk.DialogFlags.MODAL)
     69        self.add_button(xstr("button_cancel"), Gtk.ResponseType.CANCEL)
     70        self.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
     71
     72        contentArea = self.get_content_area()
     73
     74        contentAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
     75                                         xscale = 0.0, yscale = 0.0)
     76        contentAlignment.set_padding(padding_top = 4, padding_bottom = 16,
     77                                     padding_left = 8, padding_right = 8)
     78
     79        contentArea.pack_start(contentAlignment, False, False, 0)
     80
     81        contentVBox = Gtk.VBox()
     82        contentAlignment.add(contentVBox)
     83
     84        label = Gtk.Label(xstr("simbrief_mfa_code_needed"))
     85        label.set_line_wrap(True)
     86        label.set_justify(Gtk.Justification.CENTER)
     87        label.set_alignment(0.5, 0.0)
     88
     89        contentVBox.pack_start(label, False, False, 0)
     90
     91        tableAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
     92                                       xscale = 0.0, yscale = 0.0)
     93        tableAlignment.set_padding(padding_top = 24, padding_bottom = 0,
     94                                   padding_left = 0, padding_right = 0)
     95
     96        table = Gtk.Table(1, 2)
     97        table.set_row_spacings(4)
     98        table.set_col_spacings(16)
     99        table.set_homogeneous(False)
     100
     101        tableAlignment.add(table)
     102        contentVBox.pack_start(tableAlignment, True, True, 0)
     103
     104        label = Gtk.Label(xstr("simbrief_mfa_code"))
     105        label.set_use_underline(True)
     106        label.set_alignment(0.0, 0.5)
     107        table.attach(label, 0, 1, 0, 1)
     108
     109        self._mfaCode = Gtk.Entry()
     110        self._mfaCode.set_width_chars(16)
     111        self._mfaCode.set_tooltip_text(xstr("simbrief_mfa_code_tooltip"))
     112        table.attach(self._mfaCode, 1, 2, 0, 1)
     113        label.set_mnemonic_widget(self._mfaCode)
     114
     115
     116    @property
     117    def mfaCode(self):
     118        """Get the MFA code entered."""
     119        return self._mfaCode.get_text()
     120
     121    def run(self):
     122        """Run the dialog."""
     123        self.show_all()
     124
     125        response = super(SimBriefMFACodeDialog, self).run()
     126
     127        self.hide()
     128
     129        return response
     130
    59131#------------------------------------------------------------------------------
    60132
     
    82154
    83155
    84     def __init__(self):
     156    def __init__(self, gui):
    85157        """Construct the handler."""
    86158        self._browser = None
     
    92164        self._lastProgress = SIMBRIEF_PROGRESS_SEARCHING_BROWSER
    93165        self._timeoutID = None
     166        self._gui = gui
    94167
    95168    def initialize(self):
     
    155228            js +="form.submit();"
    156229            frame.ExecuteJavascript(js)
     230        elif url.startswith("https://identity.api.navigraph.com//mfaEmail"):
     231            dialog = SimBriefMFACodeDialog(self._gui)
     232            response = dialog.run()
     233
     234            if response!=Gtk.ResponseType.OK:
     235                self._updateProgress(SIMBRIEF_PROGRESS_WAITING_LOGIN,
     236                                     SIMBRIEF_RESULT_ERROR_LOGIN_FAILED, None)
     237                return
     238
     239            mfaCode = dialog.mfaCode
     240            js = "form=document.getElementById(\"form1\");"
     241            js +="form.txtcdvl.value=\"" + mfaCode + "\";"
     242            js +="form.btnApprove.click();"
     243            frame.ExecuteJavascript(js)
     244        elif url.startswith("https://identity.api.navigraph.com/mfaFailed"):
     245            self._updateProgress(SIMBRIEF_PROGRESS_WAITING_LOGIN,
     246                                 SIMBRIEF_RESULT_ERROR_LOGIN_FAILED, None)
    157247        elif url.startswith("https://www.simbrief.com/ofp/ofp.loader.api.php"):
    158248            self._updateProgress(SIMBRIEF_PROGRESS_WAITING_RESULT,
     
    201291#------------------------------------------------------------------------------
    202292
    203 def initialize(initializedCallback):
     293def initialize(initializedCallback, gui):
    204294    """Initialize the Chrome Embedded Framework."""
    205295    global _toQuit, _simBriefHandler
     
    208298    GObject.threads_init()
    209299
    210     _simBriefHandler = SimBriefHandler()
     300    _simBriefHandler = SimBriefHandler(gui)
    211301    GObject.timeout_add(100, _initializeCEF, [], initializedCallback)
    212302
  • src/mlx/gui/gui.py

    r1181 r1186  
    19991999        It checks if we already know the PID, and if not, asks the user whether
    20002000        to register."""
    2001         cef.initialize(self._cefInitialized)
     2001        cef.initialize(self._cefInitialized, self)
    20022002
    20032003        if not self.config.pilotID and not self.config.password:
Note: See TracChangeset for help on using the changeset viewer.