Manually unban a user
979260
public function preview_onUnban($recordId = null)
    {
        $model = $this->formFindModelObject($recordId);

        $model->unban();

        Flash::success(Lang::get('rainlab.user::lang.users.unbanned_success'));

        if ($redirect = $this->makeRedirect('update-close', $model)) {
            return $redirect;
        }
    }
352788
def clean_username(self):
        
        try:
            user = get_user_model().objects.get(username__iexact=self.cleaned_data['username'])
        except get_user_model().DoesNotExist:
            pass
        else:
            if userena_settings.USERENA_ACTIVATION_REQUIRED and UserenaSignup.objects.filter(user__username__iexact=self.cleaned_data['username']).exclude(activation_key=userena_settings.USERENA_ACTIVATED):
                raise forms.ValidationError(_('This username is already taken but not confirmed. Please check your email for verification steps.'))
            raise forms.ValidationError(_('This username is already taken.'))
        if self.cleaned_data['username'].lower() in userena_settings.USERENA_FORBIDDEN_USERNAMES:
            raise forms.ValidationError(_('This username is not allowed.'))
        return self.cleaned_data['username']
325481
def ban_user(self, room_id, user_id, reason=""):
        
        body = {
            "user_id": user_id,
            "reason": reason
        }
        return self._send("POST", "/rooms/" + room_id + "/ban", body)
758193
def remove_handler():
    """"""
    logger.debug("[#] Removing user, group and permissions for Blockade")
    client = boto3.client("iam", region_name=PRIMARY_REGION)

    iam = boto3.resource('iam')
    account_id = iam.CurrentUser().arn.split(':')[4]

    try:
        logger.debug("[#] Removing %s from %s group" % (BLOCKADE_USER, BLOCKADE_GROUP))
        response = client.remove_user_from_group(
            GroupName=BLOCKADE_GROUP,
            UserName=BLOCKADE_USER
        )
    except client.exceptions.NoSuchEntityException:
        logger.debug("[!] Blockade user already removed from group")

    for label in BLOCKADE_POLICIES + ['PushToCloud', 'APIGatewayAdmin']:
        logger.debug("[#] Removing %s policy" % (label))
        arn = 'arn:aws:iam::{id}:policy/{policy}'.format(id=account_id,
                                                         policy=label)
        if label == 'PushToCloud':
            arn = "arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
        if label == 'APIGatewayAdmin':
            arn = "arn:aws:iam::aws:policy/AmazonAPIGatewayAdministrator"

        try:
            response = client.detach_group_policy(
                GroupName=BLOCKADE_GROUP, PolicyArn=arn)
        except:
            pass
        try:
            response = client.detach_role_policy(
                RoleName=BLOCKADE_ROLE, PolicyArn=arn)
        except:
            pass
        try:
            response = client.delete_policy(PolicyArn=arn)
        except Exception as e:
            print(e)
            pass
    logger.debug("[#] Removed all policies")

    try:
        logger.debug("[#] Deleting %s user" % (BLOCKADE_USER))
        response = client.delete_user(
            UserName=BLOCKADE_USER
        )
    except client.exceptions.NoSuchEntityException:
        logger.debug("[!] %s user already deleted" % (BLOCKADE_USER))

    try:
        logger.debug("[#] Removing %s group" % (BLOCKADE_GROUP))
        response = client.delete_group(GroupName=BLOCKADE_GROUP)
    except:
        logger.debug("[!] Group already removed")

    try:
        logger.debug("[#] Removing %s role" % (BLOCKADE_ROLE))
        response = client.delete_role(RoleName=BLOCKADE_ROLE)
    except:
        logger.debug("[!] Role already removed")

    return True
1343844
def prj_remove_user(self, *args, **kwargs):
        
        if not self.cur_prj:
            return
        i = self.prj_user_tablev.currentIndex()
        item = i.internalPointer()
        if item:
            user = item.internal_data()
            log.debug("Removing user %s.", user.username)
            item.set_parent(None)
            self.cur_prj.users.remove(user)
612264
def handle(self, user, **options):
        
        monkeypatch_remove_pages_site_restrictions()
        user_model = get_user_model()
        for match in ('username', 'pk', 'email'):
            try:
                u = user_model.objects.get(**{match: user})
                break
            except (user_model.DoesNotExist, ValueError):
                continue
        else:
            raise CommandError(_("User with username/id/email = '%s' not found")
                % user)

        json = sys.stdin.read()
        errors, pages_created = json_to_pages(json, u)
        if errors:
            for e in errors:
                sys.stderr.write(e + '\n')
            raise CommandError(_("Errors encountered while importing JSON"))
        for page, created, messages in pages_created:
            print((_("%s created.") if created else _("%s modified.")) % (
                page.get_complete_slug()))
            for m in messages:
                print(" - " + m)
920374
def unblock(self, other_user_id):
        
        params = {'user': self.user_id, 'otherUser': other_user_id}
        response = self.session.delete(self.url, params=params)
        return response.ok
1345489
async def delete_user(name):
    """"""
    app_log.info("Deleting user %s", name)
    await api_request('users/{}/server'.format(name), method='DELETE')
    await api_request('users/{}'.format(name), method='DELETE')
665593
def revoke_admin():
    """"""
    build = g.build
    form = forms.RemoveAdminForm()
    if form.validate_on_submit():
        user = models.User.query.get(form.user_id.data)
        if not user:
            logging.debug('User being revoked admin access does not exist.'
                          'id=%r, build_id=%r', form.user_id.data, build.id)
            abort(400)

        if user == current_user:
            logging.debug('User trying to remove themself as admin. '
                          'id=%r, build_id=%r', user.id, build.id)
            abort(400)

        db.session.add(build)
        db.session.add(user)
        db.session.refresh(build, lockmode='update')
        db.session.refresh(user, lockmode='update')

        user_is_owner = build.owners.filter_by(id=user.id)
        if not user_is_owner:
            logging.debug('User being revoked admin access is not owner. '
                          'id=%r, build_id=%r.', user.id, build.id)
            abort(400)

        build.owners.remove(user)
        save_admin_log(build, revoked_admin=True, message=user.email_address)

        db.session.commit()

        operations.UserOps(user.get_id()).evict()

    return redirect(url_for('manage_admins', build_id=build.id))
202413
def clean_username(self):
        
        try: 
            user = get_user_model().objects.get(username=self.cleaned_data["username"])
        except get_user_model().DoesNotExist: 
            pass
        else: 
            raise forms.ValidationError(
                            self.error_messages['duplicate_username'])

        if self.cleaned_data['username'].lower() \
            in defaults.ACCOUNTS_FORBIDDEN_USERNAMES:
            raise forms.ValidationError(_(u'This username is not allowed.'))
        return self.cleaned_data['username']
1276368
def delete_user(self, user):
        
        assert self.user == 'catroot' or self.user == 'postgres'
        assert not user == 'public'
        con = self.connection or self._connect()
        cur = con.cursor()
        cur.execute('DROP SCHEMA {user} CASCADE;'.format(user=user))
        cur.execute('REVOKE USAGE ON SCHEMA public FROM {user};'
                    .format(user=user))
        cur.execute(
            'REVOKE SELECT ON ALL TABLES IN SCHEMA public FROM {user};'
            .format(user=user))
        cur.execute(
            'DROP ROLE {user};'.format(user=user))
        self.stdout.write(
            'REMOVED USER {user}\n'.format(user=user))

        if self.connection is None:
            con.commit()
            con.close()

        return self
1011695
public function onBanSelf()
    {
        $rulesToRemove = ['notSubmitterIpHostname'];
        $rules         = (array) array_get($this->rules, 'value', []);

        foreach ($rules as $index => $rule) {
            if (in_array($rule, $rulesToRemove, true)) {
                unset($this->rules['value'][$index]);
            }
        }
    }
919325
def delete(self, user):
        
        self._check_auth(must_admin=True)
        is_admin = self._check_admin()
        try:
            referer = cherrypy.request.headers['Referer']
        except Exception as e:
            referer = '/'
        self._deleteuser(user)
        self._add_notification('User Deleted')
        raise cherrypy.HTTPRedirect(referer)
292997
def delete_user(name, runas=None):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    res = __salt__['cmd.run_all'](
        [RABBITMQCTL, 'delete_user', name],
        reset_system_locale=False,
        python_shell=False,
        runas=runas)
    msg = 'Deleted'

    return _format_response(res, msg)
1205230
def kick_user(self, jid):
        """"""
        for member in filter(lambda m: m['JID'] == jid, self.params['MEMBERS']):
            member['STATUS'] = 'KICKED'
            self.send_message('You have been kicked from %s' % (self.name,), member)

            self.client.sendPresence(jid=member['JID'], typ='unsubscribed')
            self.client.sendPresence(jid=member['JID'], typ='unsubscribe')
            self.broadcast('kicking %s from the room' % (jid,))
581843
def unbind(self, binding):
        
        
        username = self.backend.config.generate_binding_username(binding)
        
        try:
            self.backend.atlas.DatabaseUsers.delete_a_database_user(username)
        except ErrAtlasNotFound:
            # The user does not exist. This is not an issue because this is possible that we
            # removed it in a previous call that failed later on the broker.
            # This cover a manually deleted user case too.
            pass

        self.backend.storage.remove(binding)
1299152
async def disable(self):
        
        await self.controller.disable_user(self.username)
        self._user_info.disabled = True