Esempio n. 1
0
            def walk(branch):
                """Inspect a schema recursively to translate descriptions and titles"""

                if isinstance(branch, dict):

                    if "title" in branch and isinstance(branch["title"], str):
                        # schemata_log(branch['title'])
                        branch["title"] = _(branch["title"], lang=lang)
                    if "description" in branch and isinstance(
                            branch["description"], str):
                        # schemata_log(branch['description'])
                        branch["description"] = _(branch["description"],
                                                  lang=lang)

                    for branch_item in branch.values():
                        walk(branch_item)
Esempio n. 2
0
    def enrol(self, event):
        """A user tries to self-enrol with the enrolment form"""

        if self.config.allow_registration is False:
            self.log('Someone tried to register although enrolment is closed.')
            return

        self.log('Client trying to register a new account:', event, pretty=True)
        # self.log(event.data, pretty=True)

        uuid = event.client.uuid

        if uuid in self.captchas and event.data.get('captcha', None) == \
                self.captchas[uuid]['text']:
            self.log('Captcha solved!')
        else:
            self.log('Captcha failed!')
            self._fail(event, _('You did not solve the captcha correctly.', event))
            self._generate_captcha(event)

            return

        mail = event.data.get('mail', None)
        if mail is None:
            self._fail(event, _('You have to supply all required fields.', event))
            return
        elif not validate_email(mail):
            self._fail(event, _('The supplied email address seems invalid', event))
            return

        if objectmodels['user'].count({'mail': mail}) > 0:
            self._fail(event, _('Your mail address cannot be used.', event))
            return

        password = event.data.get('password', None)
        if password is None or len(password) < 5:
            self._fail(event, _('Your password is not long enough.', event))
            return

        username = event.data.get('username', None)
        if username is None or len(username) < 1:
            self._fail(event, _('Your username is not long enough.', event))
            return
        elif (objectmodels['user'].count({'name': username}) > 0) or \
                (objectmodels['enrollment'].count({'name': username}) > 0):
            self._fail(event, _('The username you supplied is not available.', event))
            return

        self.log('Provided data is good to enrol.')
        if self.config.no_verify:
            self._create_user(username, password, mail, 'Enrolled', uuid)
        else:
            self._invite(username, 'Enrolled', mail, uuid, event, password)
Esempio n. 3
0
    def client_details(self, *args):
        """Display known details about a given client"""

        self.log(_("Client details:", lang="de"))
        client = self._clients[args[0]]

        self.log(
            "UUID:",
            client.uuid,
            "IP:",
            client.ip,
            "Name:",
            client.name,
            "User:",
            self._users[client.useruuid],
            pretty=True,
        )
Esempio n. 4
0
    def _handle_authorized_events(self, component, action, data, user, client):
        """Isolated communication link for authorized events."""

        try:
            if component == "debugger":
                self.log(component, action, data, user, client, lvl=info)

            if not user and component in self.authorized_events.keys():
                self.log(
                    "Unknown client tried to do an authenticated operation: %s",
                    component,
                    action,
                    data,
                    user,
                )
                return

            event = self.authorized_events[component][action]["event"](
                user, action, data, client
            )

            self.log("Authorized event roles:", event.roles, lvl=verbose)
            if not self._check_permissions(user, event):
                result = {
                    "component": "isomer.ui.clientmanager",
                    "action": "Permission",
                    "data": _("You have no role that allows this action.", lang="de"),
                }
                self.fireEvent(send(event.client.uuid, result))
                return

            self.log("Firing authorized event: ", event, lvl=debug)
            # self.log("", (user, action, data, client), lvl=critical)
            self.fireEvent(event)
        except Exception as e:
            self.log(
                "Critical error during authorized event handling:",
                component,
                action,
                e,
                type(e),
                lvl=critical,
                exc=True,
            )
Esempio n. 5
0
Client: Clientprofile to store client specific settings


"""
from isomer.schemata.defaultform import savebutton
from isomer.schemata.base import base_object, language_field
from isomer.misc import i18n as _

ScreenRotationSchema = {
    "id": "#screenrotation",
    "type": "object",
    "properties": {
        "state": {
            "type": "string",
            "minLength": 1,
            "title": _("New State"),
            "description": _("State to switch to"),
        },
        "args": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string",
                        "title": _("Argument Name")
                    },
                    "value": {
                        "type": "string",
                        "title": _("Argument Value")
                    },
Esempio n. 6
0
"""

from isomer.schemata.defaultform import editbuttons
from isomer.schemata.base import base_object
from isomer.misc import i18n as _

NotificationSchema = base_object('notification',
                                 roles_read=['admin'],
                                 roles_write=['admin'],
                                 roles_create=['admin'],
                                 roles_list=['admin']
                                 )

NotificationSchema['properties'].update({
    'text': {
        'type': 'string', 'format': 'html', 'title': _('Text'),
        'description': _('Notification text')
    },
    'time': {
        'type': 'string',
        'format': 'datetimepicker',
        'title': _('Time'),
        'description': _('When this notification was issued')
    },
    'priority': {
        'type': 'integer',
        'default': 5,
        'title': _('Priority')
    },
    'acknowledged': {
        'type': 'boolean', 'title': _('Acknowledged'),