Easy Integration:
hwi_oauth: https://github.com/hwi/HWIOAuthBundle
fosub: https://github.com/FriendsOfSymfony/FOSUserBundle
Optional (sonatauser & sonataadmin): https://github.com/sonata-project/SonataUserBundle
This bundle integrate fosub + hwi_oauth with default options and configuration for only work. You can use it as documentation, guide or use directly in your site.
From composer, add
{
"require": {
"sopinet/userbundle": "dev-master"
}
}
Add bundle to AppKernel (you can need add FOSUB and SonataUserBundle too)
new Sopinet\UserBundle\SopinetUserBundle(),
- Add configuration / security file by default:
imports
- { resource: "@SopinetUserBundle/Resources/config/config.yml" }
instead of if you want the same login page for admin and users, then you must import this one:
imports
- { resource: "@SopinetUserBundle/Resources/config/same_login_config.yml" }
- Add your id and secret parameters:
parameters:
sopinet_user_facebook_id: "YOURID-FACEBOOK"
sopinet_user_facebook_secret: "YOURSECRET-FACEBOOK"
sopinet_user_google_id: "YOURID-GOOGLE"
sopinet_user_google_secret: "YOURSECRET-GOOGLE"
- It work with SonataUserBundle, overriding user class in app, so, you must have configure integration with FOSUB+SonataUser
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
- In your Application\Sonata\UserBundle\Entity\User you must have one field ProfilePicture:
/** @ORM\Column(name="profilepicture", type="string", length=500, nullable=true) */
protected $profilepicture;
/**
* Set profilepicture
*
* @param string $profilepicture
* @return User
*/
public function setProfilePicture($profilepicture)
{
$this->profilepicture = $profilepicture;
return $this;
}
/**
* Get profilepicture
*
* @return string
*/
public function getProfilePicture()
{
return $this->profilepicture;
}
And it must be defined in User.orm.xml
<field name="profilepicture" column="profilepicture" type="string" length="500" nullable="true"></field>
<a href="{{ hwi_oauth_login_url('google') }}">Connect with Google</a>
<a href="{{ hwi_oauth_login_url('facebook') }}">Connect with Facebook</a>