def _on_claim_user_clicked(self, action_addr: BackendInvitationAddr) -> None: widget: ClaimUserWidget @self._bind_async_callback async def _on_finished() -> None: nonlocal widget # It's safe to access the widget status here since this does not perform a Qt call. # But the underlying C++ widget might already be deleted so we should make sure not # not do anything Qt related with this widget. if not widget.status: return device, auth_method, password = widget.status self.reload_login_devices() await self.try_login(device, auth_method, password) answer = ask_question( self, _("TEXT_CLAIM_USER_SUCCESSFUL_TITLE"), _("TEXT_CLAIM_USER_SUCCESSFUL"), [_("ACTION_CREATE_RECOVERY_DEVICE"), _("ACTION_NO")], oriented_question=True, ) if answer == _("ACTION_CREATE_RECOVERY_DEVICE"): DeviceRecoveryExportWidget.show_modal(self.config, self.jobs_ctx, [device], self) widget = ClaimUserWidget.show_modal( jobs_ctx=self.jobs_ctx, config=self.config, addr=action_addr, parent=self, on_finished=_on_finished, )
def _on_claim_user_clicked(self, action_addr): ret = ClaimUserWidget.exec_modal( jobs_ctx=self.jobs_ctx, config=self.config, addr=action_addr, parent=self ) if ret: self.reload_login_devices() self.try_login(ret[0], ret[1])
def _on_claim_user_clicked(self, action_addr=None): if not action_addr: url = get_text_input( parent=self, title=_("TEXT_CLAIM_USER_URL_TITLE"), message=_("TEXT_CLAIM_USER_URL_INSTRUCTIONS"), placeholder=_("TEXT_CLAIM_USER_URL_PLACEHOLDER"), ) if url is None: return elif url == "": show_error(self, _("TEXT_CLAIM_USER_INVALID_URL")) return action_addr = None try: action_addr = BackendOrganizationClaimUserAddr.from_url(url) except ValueError as exc: show_error(self, _("TEXT_CLAIM_USER_INVALID_URL"), exception=exc) return ret = ClaimUserWidget.exec_modal( jobs_ctx=self.jobs_ctx, config=self.config, addr=action_addr, parent=self ) if ret: self.reload_login_devices()
def __init__(self, core_config, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.core_config = core_config self.login_widget = LoginLoginWidget(core_config) self.layout.insertWidget(0, self.login_widget) self.claim_user_widget = ClaimUserWidget(core_config) self.layout.insertWidget(0, self.claim_user_widget) self.claim_device_widget = ClaimDeviceWidget(core_config) self.layout.insertWidget(0, self.claim_device_widget) self.button_login_instead.clicked.connect(self.show_login_widget) self.button_register_user_instead.clicked.connect( self.show_claim_user_widget) self.button_register_device_instead.clicked.connect( self.show_claim_device_widget) self.login_widget.login_with_password_clicked.connect( self.emit_login_with_password) self.login_widget.login_with_pkcs11_clicked.connect( self.emit_login_with_pkcs11) self.claim_user_widget.user_claimed.connect(self.show_login_widget) self.claim_device_widget.device_claimed.connect(self.show_login_widget) self.button_settings.clicked.connect(self.show_settings) self.reset()
def _on_claim_user_clicked(self, action_addr): widget = None def _on_finished(): nonlocal widget if not widget.status: return login, password = widget.status self.reload_login_devices() self.try_login(login, password) widget = ClaimUserWidget.show_modal( jobs_ctx=self.jobs_ctx, config=self.config, addr=action_addr, parent=self, on_finished=_on_finished, )
def _on_claim_user_clicked(self, action_addr: BackendInvitationAddr) -> None: widget: ClaimDeviceWidget def _on_finished() -> None: nonlocal widget if not widget.status: return device, password = widget.status self.reload_login_devices() self.try_login(device, password) widget = ClaimUserWidget.show_modal( jobs_ctx=self.jobs_ctx, config=self.config, addr=action_addr, parent=self, on_finished=_on_finished, )
class LoginWidget(QWidget, Ui_LoginWidget): login_with_password_clicked = pyqtSignal(str, str, str) login_with_pkcs11_clicked = pyqtSignal(str, str, str, int, int) def __init__(self, core_config, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.core_config = core_config self.login_widget = LoginLoginWidget(core_config) self.layout.insertWidget(0, self.login_widget) self.claim_user_widget = ClaimUserWidget(core_config) self.layout.insertWidget(0, self.claim_user_widget) self.claim_device_widget = ClaimDeviceWidget(core_config) self.layout.insertWidget(0, self.claim_device_widget) self.button_login_instead.clicked.connect(self.show_login_widget) self.button_register_user_instead.clicked.connect( self.show_claim_user_widget) self.button_register_device_instead.clicked.connect( self.show_claim_device_widget) self.login_widget.login_with_password_clicked.connect( self.emit_login_with_password) self.login_widget.login_with_pkcs11_clicked.connect( self.emit_login_with_pkcs11) self.claim_user_widget.user_claimed.connect(self.show_login_widget) self.claim_device_widget.device_claimed.connect(self.show_login_widget) self.button_settings.clicked.connect(self.show_settings) self.reset() def emit_login_with_password(self, organization_id, device_id, password): self.login_with_password_clicked.emit(organization_id, device_id, password) def emit_login_with_pkcs11(self, organization_id, device_id, pkcs11_pin, pkcs11_key, pkcs11_token): self.login_with_pkcs11_clicked.emit(organization_id, device_id, pkcs11_pin, pkcs11_key, pkcs11_token) def show_settings(self): settings_dialog = SettingsDialog(self.core_config, parent=self) settings_dialog.exec_() def show_login_widget(self): self.claim_user_widget.hide() self.claim_device_widget.hide() self.button_login_instead.hide() self.button_register_user_instead.show() self.button_register_device_instead.show() self.login_widget.reset() self.login_widget.show() def show_claim_user_widget(self): self.login_widget.hide() self.claim_device_widget.hide() self.button_login_instead.show() self.button_register_user_instead.hide() self.button_register_device_instead.show() self.claim_user_widget.reset() self.claim_user_widget.show() def show_claim_device_widget(self): self.login_widget.hide() self.claim_user_widget.hide() self.button_login_instead.show() self.button_register_user_instead.show() self.button_register_device_instead.hide() self.claim_device_widget.reset() self.claim_device_widget.show() def reset(self): self.show_login_widget() self.button_login_instead.hide() self.button_register_user_instead.show() self.button_register_device_instead.show() self.claim_user_widget.reset() self.claim_device_widget.reset() self.login_widget.reset()