Prevents users from accessing another user's account.
Except for "admins", who can access any account.
769815
function yourselfOnly(req, res, next) {
  // Get the username or sessionId from the URL
  var username = req.params.username;
  var sessionId = req.params.sessionId;

  if (!req.session) {
    res.status(401).send('You must be logged-in to access this resource');
  }
  else if (_.contains(req.session.user.roles, 'admin') ||
    (username && req.session.user.username === username) ||
    (sessionId && req.session.id === sessionId)) {
    next();
  }
  else {
    res.status(401).send('You can only perform this operation on your own account');
  }
}
117183
def unban(user, reason = nil)
      API::Server.unban_user(@bot.token, @id, user.resolve_id, reason)
    end
118606
def unlock(user):
    '''
    
    '''

    cmd = 'chuser account_locked=false {0} | ' \
          'chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s {0}'.format(user)
    ret = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=True)

    return ret
448058
def revoke_user_access(self, instance, user, db_names, strict=True):
        
        return instance.revoke_user_access(user, db_names, strict=strict)
1132203
def account_delete(request, username,
        template_name=accounts_settings.ACCOUNTS_PROFILE_DETAIL_TEMPLATE,
        extra_context=None, **kwargs):
    
    user = get_object_or_404(get_user_model(),
                             username__iexact=username)
    user.is_active = False
    user.save()

    return redirect(reverse('accounts_admin'))
228482
def allow_user(user):
    """"""
    def processor(action, argument):
        db.session.add(
            ActionUsers.allow(action, argument=argument, user_id=user.id)
        )
    return processor
233002
def access(self, user):
        """"""
        if self.denyusers:
            if user in self.denyusers:
                return False
        if self.allowusers:
            if not user in self.allowusers:
                return False
        return True
37025
def edit_user_push_restrictions(self, *users):
        
        assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in users), users

        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            self.protection_url + "/restrictions/users",
            input=users
        )
73719
public function restrictAdminBarVisibility()
    {
        // Don't go further if not logged in or within admin panel
        if (is_admin() || !is_user_logged_in())
        {
            return;
        }

        $data = $this->getData();

        // Don't go further if no setting
        if ( !isset($data['admin_bar']) || empty($data['admin_bar']))
        {
            return;
        }

        $access = $data['admin_bar'];

        // Is current user's role within our access roles?
        $user = wp_get_current_user();
        $role = $user->roles;
        $role = (count($role) > 0) ? $role[0] : '';
        $isUserIncluded = in_array($role, $access['roles']);

        // Hide admin bar if required
        if (($access['mode'] == 'show' && !$isUserIncluded)
            || ($access['mode'] == 'hide' && $isUserIncluded)
        )
        {
            show_admin_bar(false);
        }
    }
110616
protected function _allow()
    {
        $url = Wasabi::getCurrentUrlArray();
        if ($this->Guardian->isGuestAction($url)) {
            $this->Auth->allow($this->request->params['action']);
        }
    }
185444
def allow(ctx, foreign_account, permission, weight, threshold, account):
    
    if not foreign_account:
        from peerplaysbase.account import PasswordKey

        pwd = click.prompt(
            "Password for Key Derivation", hide_input=True, confirmation_prompt=True
        )
        foreign_account = format(
            PasswordKey(account, pwd, permission).get_public(), "PPY"
        )
    pprint(
        ctx.peerplays.allow(
            foreign_account,
            weight=weight,
            account=account,
            permission=permission,
            threshold=threshold,
        )
    )
1235604
def revokeSystemPermission(self, login, user, perm):
    
    self.send_revokeSystemPermission(login, user, perm)
    self.recv_revokeSystemPermission()
1365452
def disable_user():
    
    req = flask.request.get_json(force=True)
    usr = User.query.filter_by(username=req.get('username', None)).one()
    usr.is_active = False
    db.session.commit()
    return flask.jsonify(message='disabled user {}'.format(usr.username))
177967
def revoke_admin_privileges(name, **client_args):
    '''
    
    '''
    client = _client(**client_args)
    client.revoke_admin_privileges(name)

    return True
241306
def deluser(name, username):
    '''
    
    '''
    grp_info = __salt__['group.info'](name)

    if username not in grp_info['members']:
        return True

    # Note: pw exits with code 65 if group is unknown
    retcode = __salt__['cmd.retcode']('pw groupmod {0} -d {1}'.format(
        name, username), python_shell=False)

    return not retcode
788792
def grant_user_access(self, instance, user, db_names, strict=True):
        
        return instance.grant_user_access(user, db_names, strict=strict)
692827
def disable(other_user, reason)
      return false unless other_user&.system_admin?
      return false if other_user == self

      update_columns(
          disabled_by: other_user.email,
          disabled_at: Time.now,
          disabled_reason: reason,
          enabled: false
      ) && refresh_comments
    end