ユーザが削除可能かどうかをチェックします。
 @param [User] current_user ユーザ
 @return [Object]
169319
def deletable_by?(current_user)
      return nil unless current_user
      if defined?(EnjuCirculation)
        # 未返却の資料のあるユーザを削除しようとした
        if checkouts.count > 0
          errors[:base] << I18n.t('user.this_user_has_checked_out_item')
        end
      end

      if has_role?('Librarian')
        # 管理者以外のユーザが図書館員を削除しようとした。図書館員の削除は管理者しかできない
        unless current_user.has_role?('Administrator')
          errors[:base] << I18n.t('user.only_administrator_can_destroy')
        end
        # 最後の図書館員を削除しようとした
        if last_librarian?
          errors[:base] << I18n.t('user.last_librarian')
        end
      end

      # 最後の管理者を削除しようとした
      if has_role?('Administrator')
        if Role.where(name: 'Administrator').first.users.count == 1
          errors[:base] << I18n.t('user.last_administrator')
        end
      end

      if errors[:base] == []
        true
      else
        false
      end
    end
1006213
def root_snapshot
      return nil if current_snapshot.nil?

      current = current_snapshot
      current = current.parent while current.parent != nil
      current
    end
1052615
def new
      @script_author = Script::Author.new
      @script_author.user_id = current_user.id
      @script_author.org_id = current_user.org_id
    end
1084877
def index
      query = params.fetch(:q) { nil }

      respond_to do |format|
        format.json do
          render json: AudienceList.call(person: current_user, query: query)
        end
      end
    end
876317
def activate_user(self, user):
        
        if not user.active:
            user.active = True
            return True
        return False
42804
@Override
	public User getCurrentUser() {
		HttpSession session = getRequest().getSession(false);

		if (session == null)
			return null;

		return (User) session.getAttribute(SESSION_ATTR_USER);
	}
1194029
def current_user
      if (user_id = session[:user_id])
        @current_user ||= User.find_by(id: user_id)
      elsif (user_id = cookies.signed[:user_id])
        user = User.find_by(id: user_id)
        if user && user.authenticated?(cookies[:remember_token])
          log_in user
          @current_user = user
        end
      end
    end
942105
public final function getCurrentUser()
    {
        if (! self::$currentUser) {
            if ($this->session->__isset('__user_definition')) {
                $defName = $this->session->__get('__user_definition');

                // Check for during upgrade. Remove for version 1.6
                if (substr($defName, -10, 10) != 'Definition') {
                    $defName .= 'Definition';
                }

                self::$currentUser = $this->_loadClass('User', true, array($this->session, $this->_getClass($defName)));

            } else {
                if (\MUtil_Console::isConsole()) {
                    if (! $this->project->isConsoleAllowed()) {
                        echo "Accessing " . GEMS_PROJECT_NAME . " from the command line is not allowed.\n";
                        exit;
                    }


                    $request = \Zend_Controller_Front::getInstance()->getRequest();

                    if (($request instanceof \MUtil_Controller_Request_Cli) && $request->hasUserLogin()) {
                        $user = $this->getUser($request->getUserName(), $request->getUserOrganization());

                        $authResult = $user->authenticate($request->getUserPassword());
                        if (! $authResult->isValid()) {
                            echo "Invalid user login data.\n";
                            echo implode("\n", $authResult->getMessages());
                            exit;
                        }
                        self::$currentUser = $user;

                    } elseif ($this->project->getConsoleRole()) {
                        // \MUtil_Echo::track($this->request->getUserName(), $this->request->getUserOrganization());
                        self::$currentUser = $this->loadUser(self::USER_CONSOLE, 0, '(system)');
                    }

                }
                if (! self::$currentUser) {
                    self::$currentUser = $this->getUser(null, self::SYSTEM_NO_ORG);
                }
                self::$currentUser->setAsCurrentUser();
           }
        }

        return self::$currentUser;
    }
90517
def user_object(
        element_name,  # type: Text
        cls,  # type: Type[Any]
        child_processors,  # type: List[Processor]
        required=True,  # type: bool
        alias=None,  # type: Optional[Text]
        hooks=None  # type: Optional[Hooks]
):
    # type: (...) -> RootProcessor
    
    converter = _user_object_converter(cls)
    processor = _Aggregate(element_name, converter, child_processors, required, alias)
    return _processor_wrap_if_hooks(processor, hooks)
396493
def put(self, user_name: str) -> User:
        
        current = current_user()
        if current.name == user_name or current.is_admin:
            user = self._get_or_abort(user_name)
            self.update(user)
            session.commit()
            session.add(user)
            return user
        else:
            abort(403)
285303
def user_for_draftsman
      return unless defined?(current_user)
      ActiveSupport::VERSION::MAJOR >= 4 ? current_user.try!(:id) : current_user.try(:id)
    rescue NoMethodError
      current_user
    end
784352
def with_user(self, user):
        
        # N.B. doesn't cleanup query/fragment
        val = self._val
        if user is None:
            password = None
        elif isinstance(user, str):
            user = self._QUOTER(user)
            password = val.password
        else:
            raise TypeError("Invalid user type")
        if not self.is_absolute():
            raise ValueError("user replacement is not allowed " "for relative URLs")
        return URL(
            self._val._replace(
                netloc=self._make_netloc(
                    user, password, val.hostname, val.port, encode=False
                )
            ),
            encoded=True,
        )
102902
public CompletionStage<Result> currentUser() {
        return SecureSocial.currentUser(env).thenApply( new Function<Object, Result>() {
            public Result apply(Object maybeUser) {
                String id;

                if ( maybeUser != null ) {
                    DemoUser user = (DemoUser) maybeUser;
                    id = user.main.userId();
                } else {
                    id = "not available. Please log in.";
                }
                return ok("your id is " + id);
            }
        });
    }
244018
def User(self, Username=''):
        
        if not Username:
            Username = self.CurrentUserHandle
        o = User(self, Username)
        o.OnlineStatus # Test if such a user exists.
        return o
444470
def get_current_user(self):
        """"""
        url = self.current_user_url
        result = self.get(url)
        return result
79949
def current(self):
        
        if not has_request_context():
            return self.no_req_ctx_user_stack.top
        user_stack = getattr(_request_ctx_stack.top, 'user_stack', None)
        if user_stack and user_stack.top:
            return user_stack.top
        return _get_user()
387636
def prj_view_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()
            self.view_user(user)