(self, server: config.ApiServer, start_local_server=True)
| 13 | class SsoLogin(wx.Dialog): |
| 14 | |
| 15 | def __init__(self, server: config.ApiServer, start_local_server=True): |
| 16 | self.mainFrame = gui.mainFrame.MainFrame.getInstance() |
| 17 | from service.esi import Esi |
| 18 | super().__init__( |
| 19 | self.mainFrame, id=wx.ID_ANY, title=_t("SSO Login"), style=wx.DEFAULT_DIALOG_STYLE, |
| 20 | size=wx.Size(450, 240) if "wxGTK" in wx.PlatformInfo else wx.Size(400, 240)) |
| 21 | |
| 22 | bSizer1 = wx.BoxSizer(wx.VERTICAL) |
| 23 | |
| 24 | if start_local_server: |
| 25 | text = wx.StaticText(self, wx.ID_ANY, _t("Waiting for character login through EVE Single Sign-On.")) |
| 26 | bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10) |
| 27 | bSizer1.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.EXPAND, 15) |
| 28 | text = wx.StaticText(self, wx.ID_ANY, _t("If auto-login fails, copy and paste the token provided by pyfa.io")) |
| 29 | bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10) |
| 30 | elif server.name == "Serenity": |
| 31 | text = wx.StaticText(self, wx.ID_ANY, _t("Please copy and paste the url when your authorization is completed")) |
| 32 | bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10) |
| 33 | |
| 34 | else: |
| 35 | text = wx.StaticText(self, wx.ID_ANY, _t("Please copy and paste the token provided by pyfa.io")) |
| 36 | bSizer1.Add(text, 0, wx.ALL | wx.EXPAND, 10) |
| 37 | |
| 38 | self.ssoInfoCtrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (-1, -1), style=wx.TE_MULTILINE) |
| 39 | self.ssoInfoCtrl.SetFont(wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL)) |
| 40 | self.ssoInfoCtrl.Layout() |
| 41 | self.ssoInfoCtrl.Bind(wx.EVT_TEXT, self.OnTextEnter) |
| 42 | |
| 43 | bSizer1.Add(self.ssoInfoCtrl, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10) |
| 44 | |
| 45 | self.Esisettings = EsiSettings.getInstance() |
| 46 | |
| 47 | bSizer3 = wx.BoxSizer(wx.VERTICAL) |
| 48 | bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 10) |
| 49 | |
| 50 | bSizer3.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.EXPAND) |
| 51 | bSizer1.Add(bSizer3, 0, wx.ALL | wx.EXPAND, 10) |
| 52 | |
| 53 | self.SetSizer(bSizer1) |
| 54 | self.Center() |
| 55 | self.sEsi = Esi.getInstance() |
| 56 | |
| 57 | serverAddr = self.sEsi.startServer(0) if start_local_server else None |
| 58 | uri = self.sEsi.get_login_uri(serverAddr) |
| 59 | |
| 60 | if server.name == "Serenity": |
| 61 | webbrowser.open(config.SSO_LOGOFF_SERENITY) |
| 62 | time.sleep(1) |
| 63 | |
| 64 | self.okBtn = self.FindWindow(wx.ID_OK) |
| 65 | self.okBtn.Enable(False) |
| 66 | # Ensure we clean up once they hit the "OK" button |
| 67 | self.okBtn.Bind(wx.EVT_BUTTON, self.OnDestroy) |
| 68 | |
| 69 | webbrowser.open(uri) |
| 70 | |
| 71 | self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.OnLogin) |
| 72 | # Ensure we clean up if ESC is pressed |
nothing calls this directly
no test coverage detected