autologin-bundle
When you receive a notification, invitation, etc. by email with a URL to your site, you have to login everytime.
With this module, you will login automatically when you click on URL, it's too easy.
Come on!, (*1)
Prerequisites
This module works with FOSUserBundle (see Documentation), (*2)
Installation
composer.json
``` bash
$ php composer.phar require sopinet/autologin-bundle 'dev-master', (*3)
### AppKernel.php
``` php
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sopinet\AutologinBundle\SopinetAutologinBundle(),
);
}
config.yml
``` yaml, (*4)
app/config/config.yml
sopinet_autologin:
domain: http://domain.com, (*5)
### routing.yml
``` yaml
# app/config/routing.yml
sopinet_autologin:
resource: "@SopinetAutologinBundle/Resources/config/routing.yml"
prefix: /
How to use
Generate the URL, (*6)
``` php
<?php
$url = $this->container->get('urlhelper')->generateUrl($route, $user);, (*7)
$message = \Swift_Message::newInstance()
->setSubject(...)
->setFrom(...)
->setTo(...)
->setBody($this->container->get('templating')->render('your_template.html.twig', array('url' => $url)), 'text/html');
```, (*8)