PHP code example of thecolony / colony-login-bundle
1. Go to this page and download the library: Download thecolony/colony-login-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thecolony / colony-login-bundle example snippets
namespace App\Security;
use App\Entity\User;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use TheColony\ColonyLoginBundle\Security\ColonyUserProvisionerInterface;
final class ColonyUserProvisioner implements ColonyUserProvisionerInterface
{
public function __construct(
private UserRepository $users,
private EntityManagerInterface $em,
) {}
public function provision(array $claims): UserInterface
{
$sub = (string) $claims['sub'];
$user = $this->users->findOneBy(['colonySub' => $sub])
?? (new User())->setColonySub($sub);
// ... link by verified email / set profile from $claims as you wish ...
$this->em->persist($user);
$this->em->flush();
return $user;
}
}
final class ColonyLogoutHandler implements ColonyBackchannelLogoutHandlerInterface
{
public function logout(array $claims): void
{
// kill local sessions for $claims['sub'] (all of the user's sessions)
// and/or the single session $claims['sid']. Needs a session store you can
// query by subject/session id (e.g. a DB session handler with a colony_sub
// column) — native file sessions can't be looked up this way.
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.