Hromadné nastavení po přihlášení

@param string|null $loginId
@param int|null $roleId
@param int|null $unitId
@param \DateTime|null $logoutDate
@return self
558016
public function setLoginData($loginId = null, $roleId = null, $unitId = null, \DateTime $logoutDate = null)
    {
        $this->loginData = [];

        return $this->updateLoginData($loginId, $roleId, $unitId, $logoutDate);
    }
144989
public static function byRole($role)
    {
        //wyszukuje konta z podaną rolą
        return (new self)
                ->join('cms_auth_role')->on('id', 'cms_auth_id')
                ->join('cms_role', 'cms_auth_role')->on('cms_role_id', 'id')
                ->where('name', 'cms_role')->equals($role);
    }
537924
public function findByRoleId($roleId)
    {
        $select = $this->getSelect($this->getUserTableName());
        $select->where(array($this->getTableName() . '.role_id' => $roleId));
        $select->join(
            $this->getTableName(),
            $this->getTableName(). '.user_id = ' . $this->getUserTableName(). '.user_id',
            array(),
            Select::JOIN_INNER
        );
        $select->group($this->getUserTableName(). '.user_id');

        $entityPrototype = $this->getZfcUserOptions()->getUserEntityClass();

        return $this->select($select, new $entityPrototype, $this->getZfcUserHydrator());
    }
1256894
public function create($userId=null, $eventLog=null, $eventData=null)
    {
        if(is_null($userId)) throw new \Exception('User ID is required.');
        if(is_null($eventLog)) throw new \Exception('Event Log is required.');
        if(!is_numeric($userId)) throw new \Exception("Invalid User ID.");

        $id = $this->save($this->generateEntity(intval($userId), $eventLog, $eventData));
        return $id;
    }
449684
public function setRoleId(int $nb_role_id) : CNabuDataObject
    {
        if ($nb_role_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_role_id")
            );
        }
        $this->setValue('nb_role_id', $nb_role_id);
        
        return $this;
    }
916709
function cmd_logout (msg, respond) {
    var req = msg.req$

    // get token from request
    req.seneca.act("role: 'auth', get: 'token'", {tokenkey: options.tokenkey}, function (err, clienttoken) {
      if (err) {
        return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
      }

      if (!clienttoken) {
        return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
      }

      clienttoken = clienttoken.token
      // delete token
      req.seneca.act("role: 'auth', set: 'token'", {tokenkey: options.tokenkey}, function (err) {
        if (err) {
          return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
        }

        req.seneca.act("role:'user',cmd:'logout'", {token: clienttoken}, function (err) {
          if (err) {
            req.seneca.log('error ', err)
          }
          req.cookieAuth.clear()
          delete req.seneca.user
          delete req.seneca.login
          return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respond)
        })
      })
    })
  }
254156
public function findAllUsersByRoleId($roleId)
    {
        $qb = $this->createQueryBuilder('user')
            ->leftJoin('user.userRoles', 'userRole')
            ->leftJoin('userRole.role', 'role')
            ->where('role=:roleId');

        $query = $qb->getQuery();
        $query->setParameter('roleId', $roleId);

        return $query->getResult();
    }
317636
public function addUser(string $login_name, string $login_password, array $roles = []) : self
    {
        $this->users[$login_name]   = [
            'login_name'            => $login_name,
            'login_password'        => $login_password,
            'roles'                 => $roles,
        ];

        return $this;
    }
210971
public function loadUsersAssignedToRole($roleId)
    {
        $role = $this->roleService->loadRole($roleId);
        $roleAssignments = $this->roleService->getRoleAssignments($role);

        $restUsers = array();

        foreach ($roleAssignments as $roleAssignment) {
            if ($roleAssignment instanceof UserRoleAssignment) {
                $restUsers[] = $this->buildRestUserObject($roleAssignment->getUser());
            }
        }

        return $restUsers;
    }
141914
public function userCan($user_id, string $role, string $permission, $callback = null) : bool
    {
        // Usuário permamentemente liberado
        $root_user = config('acl.root_user');
        if ($user_id == $root_user) {
            \Acl\Core::traceCurrentAbilityOrigin('config');
            \Acl\Core::traceCurrentAbility($role, $permission, true);
            return true;
        }

        // Existem permissões setadas?
        $user_abilities = (new UsersPermissionsService)->getPermissionsByUserID($user_id, $role);
        if ($user_abilities === null) {
            \Acl\Core::traceCurrentAbility($role, $permission, false);
            return false;
        }

        // create,read,update ou delete == yes?
        $result = (isset($user_abilities['permissions']) && $user_abilities['permissions'][$permission] == 'yes');

        // Existe uma verificação adicional
        if ($result == true && $callback != null && is_callable($callback) && $callback() !== true) {
            \Acl\Core::traceCurrentAbilityOrigin('callback');
            \Acl\Core::traceCurrentAbility($role, $permission, false);
            return false;
        }

        \Acl\Core::traceCurrentAbility($role, $permission, $result);

        return $result;
    }
875756
public function unassignRoleFromUser($userId, $roleId)
    {
        $user = $this->userService->loadUser($userId);
        $role = $this->roleService->loadRole($roleId);

        $this->roleService->unassignRoleFromUser($role, $user);

        $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);

        return new Values\RoleAssignmentList($roleAssignments, $user->id);
    }
885033
public function removeUsersWithRole(Site $site, $userIdList, $role = null)
    {
        $q = $this
            ->db
            ->delete('ucms_site_access')
            ->condition('site_id', $site->id)
            ->condition('uid', $userIdList)
        ;

        if ($role) {
            $q->condition('role', $role);
        }

        $q->execute();

        $this->resetCache();
    }
515991
public function generateHeader($login, $key, $sessid=null)
    {
        $token = $this->generateToken($login, $key, $sessid);
        $ndate = $this->formatDate($token->getDate());
        return array(
            $this->config['header']['auth'] .': ' . $token->getType() . ' ' . $ndate . $token->getValue() . $token->getNoise(),
            $this->config['header']['ident'].': ' . $token->getIdent()
        );
    }
915975
public function hasRoleById(int $roleId): bool
    {
        if (isset($this->roles[$roleId])) {
            return true;
        }

        return false;
    }
1048452
public function editUserRole($role_id = null)
    {
        $this->setUserRole($role_id);
        $this->setTitleEditUserRole();
        $this->setBreadcrumbEditUserRole();

        $this->setData('role', $this->data_role);
        $this->setData('permissions', $this->getPermissionsUserRole(true));

        $this->submitEditUserRole();
        $this->outputEditUserRole();
    }
906162
protected function executeOperation(LdapOperationInterface $operation, LogOperation $log = null)
    {
        $lastServer = $this->connection->getServer();
        try {
            $this->connectIfNotBound($operation);
            $lastServer = $this->connection->getServer();
            $handler = $this->getOperationHandler($operation);
            $handler->setOperationDefaults($operation);
            $this->logStart($log);
            $this->invalidateCacheIfNeeded($operation);
            list($result, $usedCache, $cacheKey) = $this->getCacheOrHandlerResult($operation, $handler, $log);
            $this->cacheResultIfNeeded($operation, $result, $usedCache, $cacheKey);

            return $result;
        } catch (\Throwable $e) {
            $this->logExceptionAndThrow($e, $log);
        } catch (\Exception $e) {
            $this->logExceptionAndThrow($e, $log);
        } finally {
            $this->logEnd($log);
            // It would not have set controls or switched servers if the cache was used...
            if (isset($usedCache) && $usedCache === false) {
                $this->resetLdapControls($operation);
                $this->switchServerIfNeeded($this->connection->getServer(), $lastServer, $operation);
            }
            $this->dispatcher->dispatch(new LdapOperationEvent(Event::LDAP_OPERATION_EXECUTE_AFTER, $operation, $this->connection));
        }
    }
505688
public function prune($loginLog = null)
    {
        if ($loginLog) {
            $this->addUsingAlias(LoginLogTableMap::COL_ID, $loginLog->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }