Exemplo n.º 1
0
    def _on_invite_user_success(self, job):
        assert job.is_finished()
        assert job.status == "ok"

        email, invitation_addr, email_sent_status = job.ret
        if email_sent_status == InvitationEmailSentStatus.SUCCESS:
            SnackbarManager.inform(
                _("TEXT_USER_INVITE_SUCCESS_email").format(email=email))
        elif email_sent_status == InvitationEmailSentStatus.BAD_RECIPIENT:
            show_info_copy_link(
                self,
                _("TEXT_EMAIL_FAILED_TO_SEND_TITLE"),
                _("TEXT_INVITE_USER_EMAIL_BAD_RECIPIENT_directlink").format(
                    directlink=invitation_addr),
                _("ACTION_COPY_ADDR"),
                str(invitation_addr),
            )
        else:
            show_info_copy_link(
                self,
                _("TEXT_EMAIL_FAILED_TO_SEND_TITLE"),
                _("TEXT_INVITE_USER_EMAIL_NOT_AVAILABLE_directlink").format(
                    directlink=invitation_addr),
                _("ACTION_COPY_ADDR"),
                str(invitation_addr),
            )

        self.reset()
Exemplo n.º 2
0
    async def _finalize_enrollment(self, context):
        try:
            context = await context.finalize()
        except PkiEnrollmentCertificateNotFoundError:
            # Nothing to do, the user cancelled the certificate selection prompt
            return
        except PkiEnrollmentCertificatePinCodeUnavailableError:
            # Nothing to do, the user cancelled the pin code prompt
            return
        except Exception as exc:
            show_error(self,
                       _("TEXT_ENROLLMENT_CANNOT_FINALIZE"),
                       exception=exc)
            return

        try:
            await save_device_with_smartcard_in_config(
                config_dir=self.config.config_dir,
                device=context.new_device,
                certificate_id=context.x509_certificate.certificate_id,
                certificate_sha1=context.x509_certificate.certificate_sha1,
            )
        except Exception as exc:
            show_error(self, _("TEXT_CANNOT_SAVE_DEVICE"), exception=exc)
            return

        await self._remove_enrollment(context)
        SnackbarManager.inform(_("TEXT_CLAIM_DEVICE_SUCCESSFUL"))
Exemplo n.º 3
0
    def _on_send_email_success(self, job):
        # In theory the invitation address shouldn't have changed, but better safe than sorry

        self.invite_addr, email_sent_status = job.ret

        if email_sent_status == InvitationEmailSentStatus.SUCCESS:
            self.button_send_email.setText(_("TEXT_GREET_DEVICE_EMAIL_SENT"))
            self.button_send_email.setDisabled(True)
            SnackbarManager.inform(
                _("TEXT_GREET_DEVICE_EMAIL_SENT_email").format(
                    email=self.core.device.human_handle.email))
        else:
            if email_sent_status == InvitationEmailSentStatus.BAD_RECIPIENT:
                show_info_copy_link(
                    self,
                    _("TEXT_EMAIL_FAILED_TO_SEND_TITLE"),
                    _("TEXT_INVITE_DEVICE_EMAIL_BAD_RECIPIENT_directlink").
                    format(directlink=self.invite_addr),
                    _("ACTION_COPY_ADDR"),
                    str(self.invite_addr),
                )
            else:
                show_info_copy_link(
                    self,
                    _("TEXT_EMAIL_FAILED_TO_SEND_TITLE"),
                    _("TEXT_INVITE_DEVICE_EMAIL_NOT_AVAILABLE_directlink").
                    format(directlink=self.invite_addr),
                    _("ACTION_COPY_ADDR"),
                    str(self.invite_addr),
                )
            self.button_send_email.setDisabled(False)
Exemplo n.º 4
0
 def _on_get_enrollment_addr_clicked(self):
     ba = BackendPkiEnrollmentAddr.build(
         self.core.device.organization_addr.get_backend_addr(),
         self.core.device.organization_addr.organization_id,
     )
     desktop.copy_to_clipboard(ba.to_url())
     SnackbarManager.inform(
         translate("TEXT_ENROLLMENT_ADDR_COPIED_TO_CLIPBOARD"))
Exemplo n.º 5
0
 def on_get_file_path_clicked(self):
     files = self.table_files.selected_files()
     if len(files) != 1:
         return
     path = self.current_directory / files[0].name
     addr = self.workspace_fs.generate_file_link(path)
     desktop.copy_to_clipboard(addr.to_url())
     SnackbarManager.inform(_("TEXT_FILE_LINK_COPIED_TO_CLIPBOARD"))
Exemplo n.º 6
0
 async def reject_recruit(self, enrollment_button):
     try:
         await enrollment_button.pending.reject()
     except Exception:
         SnackbarManager.warn(translate("TEXT_ENROLLMENT_REJECT_FAILURE"))
         enrollment_button.set_buttons_enabled(True)
     else:
         SnackbarManager.inform(translate("TEXT_ENROLLMENT_REJECT_SUCCESS"))
         self.main_layout.removeWidget(enrollment_button)
         enrollment_button.hide()
         enrollment_button.setParent(None)
Exemplo n.º 7
0
    def switch_to_login_tab(
        self, file_link_addr: Optional[BackendOrganizationFileLinkAddr] = None
    ) -> None:
        # Retrieve the login tab
        idx = self._get_login_tab_index()
        if idx != -1:
            self.switch_to_tab(idx)
        else:
            # No loging tab, create one
            tab = self.add_new_tab()
            tab.show_login_widget()
            self.on_tab_state_changed(tab, "login")
            idx = self.tab_center.count() - 1
            self.switch_to_tab(idx)

        if not file_link_addr:
            # We're done here
            return

        # Find the device corresponding to the organization in the link
        for available_device in list_available_devices(self.config.config_dir):
            if available_device.organization_id == file_link_addr.organization_id:
                break

        else:
            # Cannot reach this organization with our available devices
            show_error(
                self,
                _("TEXT_FILE_LINK_NOT_IN_ORG_organization").format(
                    organization=file_link_addr.organization_id
                ),
            )
            return

        # Pre-select the corresponding device
        login_w = self.tab_center.widget(idx).get_login_widget()
        login_w._on_account_clicked(available_device)

        # Set the path
        instance_widget = self.tab_center.widget(idx)
        instance_widget.set_workspace_path(file_link_addr)

        # Prompt the user for the need to log in first
        SnackbarManager.inform(
            _("TEXT_FILE_LINK_PLEASE_LOG_IN_organization").format(
                organization=file_link_addr.organization_id
            )
        )
Exemplo n.º 8
0
 async def accept_recruit(self, enrollment_button, human_handle,
                          device_label, profile):
     try:
         await enrollment_button.pending.accept(
             author=self.core.device,
             device_label=device_label,
             human_handle=human_handle,
             profile=profile,
         )
     except Exception:
         SnackbarManager.warn(translate("TEXT_ENROLLMENT_ACCEPT_FAILURE"))
         enrollment_button.set_buttons_enabled(True)
     else:
         SnackbarManager.inform(translate("TEXT_ENROLLMENT_ACCEPT_SUCCESS"))
         self.main_layout.removeWidget(enrollment_button)
         enrollment_button.hide()
         enrollment_button.setParent(None)
Exemplo n.º 9
0
    def _on_revoke_success(self, job):
        assert job.is_finished()
        assert job.status == "ok"

        user_info = job.ret
        SnackbarManager.inform(
            _("TEXT_USER_REVOKE_SUCCESS_user").format(
                user=user_info.short_user_display),
            timeout=5000,
        )
        for i in range(self.layout_users.count()):
            item = self.layout_users.itemAt(i)
            if item:
                button = item.widget()
                if (button and isinstance(button, UserButton)
                        and button.user_info.user_id == user_info.user_id):
                    button.user_info = user_info
Exemplo n.º 10
0
 def _on_share_error(self, job):
     reset = True
     user_info = job.exc.params.get("user_info")
     role = job.exc.params.get("role")
     workspace_name = job.exc.params.get("workspace_name")
     sharing_widget = self._get_sharing_widget(user_info.user_id)
     if sharing_widget:
         sharing_widget.set_status_update_failed()
     if job.status == "offline":
         SnackbarManager.warn(_("TEXT_WORKSPACE_SHARING_OFFLINE"))
         reset = False
     elif role == NOT_SHARED_KEY:
         SnackbarManager.warn(
             _("TEXT_WORKSPACE_SHARING_UNSHARE_ERROR_workspace-user").format(
                 workspace=workspace_name, user=user_info.short_user_display
             )
         )
     else:
         SnackbarManager.warn(
             _("TEXT_WORKSPACE_SHARING_SHARE_ERROR_workspace-user").format(
                 workspace=workspace_name, user=user_info.short_user_display
             )
         )
     if reset:
         self.reset()
Exemplo n.º 11
0
    def _on_share_success(self, job):
        user_info, new_role, workspace_name = job.ret
        old_role = None

        self.has_changes = True
        sharing_widget = self._get_sharing_widget(user_info.user_id)
        if sharing_widget:
            sharing_widget.set_status_updated()
            old_role = sharing_widget.role
            sharing_widget.role = new_role
        if old_role is None:
            SnackbarManager.inform(
                _("TEXT_WORKSPACE_SHARING_NEW_OK_workspace-user").format(
                    workspace=workspace_name, user=user_info.short_user_display
                )
            )
        elif new_role is None:
            SnackbarManager.inform(
                _("TEXT_WORKSPACE_SHARING_REMOVED_OK_workspace-user").format(
                    workspace=workspace_name, user=user_info.short_user_display
                )
            )
        else:
            SnackbarManager.inform(
                _("TEXT_WORKSPACE_SHARING_UPDATED_workspace-user").format(
                    workspace=workspace_name, user=user_info.short_user_display
                )
            )
Exemplo n.º 12
0
 def on_new_notification(self, notif_type: str, msg: str) -> None:
     if notif_type == "CONGRATULATE":
         SnackbarManager.congratulate(msg)
     elif notif_type == "WARN":
         SnackbarManager.warn(msg)
     else:
         SnackbarManager.inform(msg)
Exemplo n.º 13
0
 def copy_to_clipboard(self):
     desktop.copy_to_clipboard(self.text_details.toPlainText())
     SnackbarManager.inform(_("TEXT_STACKTRACE_COPIED_TO_CLIPBOARD"))
Exemplo n.º 14
0
 def _on_copy_addr_clicked(self):
     desktop.copy_to_clipboard(self.invite_addr.to_url())
     SnackbarManager.inform(_("TEXT_GREET_DEVICE_ADDR_COPIED_TO_CLIPBOARD"))
Exemplo n.º 15
0
 def _on_copy_backend_addr(self) -> None:
     desktop.copy_to_clipboard(self.core.device.organization_addr.to_url())
     SnackbarManager.inform(_("TEXT_BACKEND_ADDR_COPIED_TO_CLIPBOARD"))
Exemplo n.º 16
0
 def copy_email(self):
     desktop.copy_to_clipboard(self.email)
     SnackbarManager.inform(_("TEXT_GREET_USER_EMAIL_COPIED_TO_CLIPBOARD"))
Exemplo n.º 17
0
 def copy_addr(self):
     desktop.copy_to_clipboard(str(self.addr))
     SnackbarManager.inform(_("TEXT_GREET_USER_ADDR_COPIED_TO_CLIPBOARD"))
Exemplo n.º 18
0
 def _on_cancel_invitation_success(self, job):
     assert job.is_finished()
     assert job.status == "ok"
     SnackbarManager.inform(_("TEXT_USER_INVITATION_CANCELLED"))
     self.reset()