Is the specified user an admin
178766
def _is_admin(user_id):
    
    user = get_session().query(User).filter(User.id==user_id).one()

    if user.is_admin():
        return True
    else:
        return False
452319
def can_edit(self, user):
        """"""
        return user.is_admin or not self.is_locked and self in user.admin_for
922515
def add_user(self, user, is_admin=False):
        
        users_count = self.users.all().count()
        if users_count == 0:
            is_admin = True
        # TODO get specific org user?
        org_user = self._org_user_model.objects.create(
            user=user, organization=self, is_admin=is_admin
        )
        if users_count == 0:
            # TODO get specific org user?
            self._org_owner_model.objects.create(
                organization=self, organization_user=org_user
            )

        # User added signal
        user_added.send(sender=self, user=user)
        return org_user
972809
protected function setupAdministrator()
    {
        $question = new ConfirmationQuestion('Would you like to create default administrator user (Recommended)? [y/n] ', true);
        if (!$this->helper->ask($this->input, $this->output, $question)) {
            return;
        }

        $this->runCommand('avoo:user:create');
    }
1065641
public function canAdministrate()
    {
        $user = $this->getUser();
        if ($user->name == 'Guest' && $user->email == 'guest@example.com') {
            return false;
        }
        if (method_exists($user, 'isAdmin')) {
            return $user->isAdmin();
        }
        if (method_exists($user, 'can')) {
            return $user->can('administrate') || $user->can('admin');
        }
        // If no method of authorizing return false;
        return false;
    }
1365427
def admin?
    is_admin = ( ENV['USER'] == 'root' )
    unless is_admin
      ext_admin = exec(:check_admin) do |op, results|
        if op == :reduce
          results.values.include?(true)
        else
          results ? true : false
        end
      end
    end
    is_admin || ext_admin ? true : false
  end
5101
def can_view(self, user):
        """"""
        return user.is_admin or self == user \
            or set(self.classes).intersection(user.admin_for)
149185
def ensure_compatible_admin(view):
    

    def wrapper(request, *args, **kwargs):
        user_roles = request.user.user_data.get('roles', [])
        if len(user_roles) != 1:
            context = {
                'message': 'I need to be able to manage user accounts. '
                           'My username is %s' % request.user.username
            }
            return render(request, 'mtp_common/user_admin/incompatible-admin.html', context=context)
        return view(request, *args, **kwargs)

    return wrapper
742868
def check_is_admin(context):
    """"""
    init()
    credentials = context.to_policy_values()
    target = credentials
    return _ENFORCER.authorize('admin_required', target, credentials)
782559
private function checkAdminUser($wtname, $wtuser, $wtpass, $wtemail): string
    {
        if ($wtname === '' || $wtuser === '' || $wtpass === '' || $wtemail === '') {
            return I18N::translate('You must enter all the administrator account fields.');
        }

        if (mb_strlen($wtpass) < 6) {
            return I18N::translate('The password needs to be at least six characters long.');
        }

        return '';
    }
1234991
public function isUserSuperAdministrator($userId) {
        $result = DB::table('user_group')
            ->where('user_id', $userId)
            ->where('group_id', 3)
            ->first()
        ;

        if (!$result) {
            return false;
        }

        return true;
    }
1059244
function createAdminUser(app, result, callback) {
  // Create the admin user.
  var User = app.type('user');
  var userData = {
    username: result.adminName,
    password: result.adminPass,
    email: result.adminEmail,
    roles: ['administrator']
  };
  User.validateAndSave(userData, callback);
}
620152
def is_user(self, organisation_id):
        """"""
        return (self._has_role(organisation_id, self.roles.user) or
                self.is_org_admin(organisation_id))
1139876
def get_admins(self):
        """"""
        # no nickserv support, assume people are who they say they are.
        if not self.config['feature'].getboolean('nickserv'):
            return
        with self.db.session_scope() as session:
            for a in session.query(orm.Permissions).all():
                if not a.registered:
                    self.update_authstatus(a.nick)
287092
def permitted?(requested_flags = 0)
      current_user_roles.any?{|ug| ug.admin?} ||
      current_model_permissions.any?{|cp| cp.permitted?(requested_flags)}
    end
370353
def basic_set_of_users_exists_in_the_database(context):
    
    user_model = get_user_model()
    user_model.objects.create(
        username='administrator',
        is_staff=True
    )
    user_model.objects.create(
        username='allowed_user'
    )
    user_model.objects.create(
        username='unallowed_user'
    )
617348
def match_user
      unless admin?
        user = User.find(current_user)

        unless user.id == set_user.id
          redirect_to user_path(current_user), notice: 'You do not have any permission to grant this page !'
        end
      end
    end