After that user is logged-in

@param AdminUser $user

@return string session id
973605
public function setUserLoggedIn(AdminUser $user): string
    {
        $_SESSION['admin_logged'] = true;
        $_SESSION['admin_id'] = $user->getId();
        $_SESSION['admin_login'] = $user->getLogin();
        $_SESSION['admin_sid'] = Users::getInstance()->startSession($user->getId());

        if (!defined('USER_ID')) {
            define('USER_ID', $user->getId());
        }

        App::add('User "' . $user->getLogin() . '" logged in.');

        return $_SESSION['admin_sid'];
    }
974505
public function verify(User $user, $byAdmin = false)
    {
        return $this->save($user->verify($byAdmin));
    }
650051
public function postLogin (Request $request, \Neuron\Interfaces\Models\User $user, $registered = false)
    {
        $parameters = array();
        if ($registered) {
            $parameters['registered'] = 1;
        }

        // Also set in session... why wouldn't this be in session? :D
        $request->getSession()->set('userJustRegistered', $registered);

        $this->trigger('user:login', [
            'request' => $request,
            'user' => $user,
            'registered' => $registered
        ]);

        // Should skip welcome screen?
        if ($request->getSession()->get('skip-welcome-redirect')) {
            $redirectUrl = $this->getAndClearPostLoginRedirect($request);
            return Response::redirect($redirectUrl);
        }

        return $this->redirectToWelcome ([]);
    }
172711
public function addUser($user)
    {
        if (!$this->hasUser($user)) {
            return RoleUser::create(['role_id' => $this->id, 'user_id' => $user->id]);
        }

        return false;
    }
1173382
public function persistUser(User $user)
    {
        $this->objectManager->persist($user);
        $this->objectManager->flush();

        return $user;
    }
956826
private function getUsernameForGitHubMatching(User $user)
    {
        $identity = $user->identities()->first();

        if ($identity->provider()->type() === IdentityProviderEnum::TYPE_INTERNAL) {
            return $user->name();
        } elseif ($identity->provider()->type() === IdentityProviderEnum::TYPE_LDAP) {
            return $identity->providerUniqueID();
        }

        return $user->name();
    }
400354
private function fetch(User $user)
    {
        return self::$cache[$user->getId()] = new \ACL($user, $this->app);
    }
851114
public function roles(User $user)
    {
        if ($this->session->hasValue(Roles::SESSION_KEY)) {
            return $this->session->value(Roles::SESSION_KEY);
        }

        $roles = $this->authorizationProvider->roles($user);
        $this->session->putValue(Roles::SESSION_KEY, $roles);
        return $roles;
    }
879088
public function getUserEndorsement($user) {
        return $this->endorsements->filter(function($e) use ($user) {
                    return $e->getUser() == $user;
                })->first();
    }
889958
protected function getUserId($user)
    {
        if (is_null($user))
        {
            $user = auth()->user();
        }

        if ($user instanceof Model)
        {
            $user = $user->getKey();
        }

        return $user;
    }
1147027
public function getUser()
    {
        /** @var AbstractAdmin $admin */
        $admin = $this;

        $container = $admin->getContainer();

        if (!$container->has('security.token_storage')) {
            return null;
        }

        $tokenStorage = $container->get('security.token_storage');

        if (null === $token = $tokenStorage->getToken()) {
            return null;
        }

        if (!\is_object($user = $token->getUser())) {
            // e.g. anonymous authentication
            return null;
        }

        return $user;
    }
102876
public function userCreate($user)
    {
        $this->dispatchHooks('BeforeUserCreateScope', $user);
        $this->parseEntityFields('user', $user);
        $this->getDriver()->userCreate($user);
        $this->dispatchHooks('AfterUserCreateScope', $user);
        $this->userManager->addUser($user);
        return $user;
    }
157543
public function getUserFromSession(Session $session)
    {
        $cl = $this->getUserClass();
        $this->user = new $cl;
        $this->user->obtainFromSession($session);
        return $this->user;
    }
1129044
public static function login_user(\stdClass $user) {
        global $DB;

        // Regenerate session id and delete old session,
        // this helps prevent session fixation attacks from the same domain.

        $sid = session_id();
        session_regenerate_id(true);
        $DB->delete_records('sessions', array('sid'=>$sid));
        self::add_session_record($user->id);

        // Let enrol plugins deal with new enrolments if necessary.
        enrol_check_plugins($user);

        // Setup $USER object.
        self::set_user($user);
    }
195246
public static function getRecent($user)
    {
        $records = static::where('user_id', $user->id)
            ->orderBy('created_at', 'desc')
            ->limit(2)
            ->get()
        ;

        if (!count($records)) {
            return null;
        }

        $first = $records->first();

        return !$first->created_at->isToday() ? $first : $records->pop();
    }
1174518
protected function getUserId()
    {
        $user = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
        if ($user->loadAdminUser()) {
            return $user->getId();
        }
    }
698481
public function saveUser($user) {
        global $DB;

        $now = time();
        $isinsert = is_null($user->created);
        $user->updated = $now;

        $params = [
            'ltiresultsourcedid' => $user->ltiResultSourcedId,
            'updated' => $user->updated
        ];

        if ($isinsert) {
            $params['resourcelinkid'] = $user->getResourceLink()->getRecordId();
            $params['ltiuserkey'] = $user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY);
            $user->created = $now;
            $params['created'] = $user->created;
            $id = $DB->insert_record($this->userresulttable, (object) $params);
            if ($id) {
                $user->setRecordId($id);
                return true;
            }

        } else {
            $params['id'] = $user->getRecordId();
            return $DB->update_record($this->userresulttable, (object) $params);
        }

        return false;
    }