Ejemplo n.º 1
0
    def save(self, commit=True):
        """Set hostname, create and login the user"""
        config.set_hostname(self.cleaned_data['hostname'])
        user = super(State0Form, self).save(commit=False)
        user.set_password(self.cleaned_data['password'])
        if commit:
            user.save()

            try:
                actions.superuser_run(
                    'ldap',
                    ['create-user', user.get_username()],
                    input=self.cleaned_data['password'].encode())
            except ActionError:
                messages.error(self.request,
                               _('Creating LDAP user failed.'))

            try:
                actions.superuser_run(
                    'ldap',
                    ['add-user-to-group', user.get_username(), 'admin'])
            except ActionError:
                messages.error(self.request,
                               _('Failed to add new user to admin group.'))

            # Create initial Django groups
            for group_choice in GROUP_CHOICES:
                auth.models.Group.objects.get_or_create(name=group_choice[0])

            admin_group = auth.models.Group.objects.get(name='admin')
            admin_group.user_set.add(user)

            self.login_user()

        return user
Ejemplo n.º 2
0
    def save(self, commit=True):
        """Set hostname, create and login the user"""
        config.set_hostname(self.cleaned_data['hostname'])
        user = super(State0Form, self).save(commit=False)
        user.set_password(self.cleaned_data['password'])
        if commit:
            user.save()
            self.login_user()

        return user
Ejemplo n.º 3
0
    def save(self, commit=True):
        """Set hostname, create and login the user"""
        config.set_hostname(self.cleaned_data['hostname'])
        user = super(State0Form, self).save(commit=False)
        user.set_password(self.cleaned_data['password'])
        if commit:
            user.save()
            try:
                actions.superuser_run(
                    'create-user',
                    [user.get_username(), self.cleaned_data['password']])
            except ActionError:
                messages.error(self.request,
                               _('Creating POSIX system user failed.'))
            self.login_user()

        return user
Ejemplo n.º 4
0
    def save(self, commit=True):
        """Set hostname, create and login the user"""
        config.set_hostname(self.cleaned_data['hostname'])
        user = super(State0Form, self).save(commit=False)
        user.set_password(self.cleaned_data['password'])
        if commit:
            user.save()
            try:
                actions.superuser_run(
                    'create-user',
                    [user.get_username(), self.cleaned_data['password']])
            except ActionError:
                messages.error(self.request,
                               _('Creating POSIX system user failed.'))
            self.login_user()

        return user