Sopinet/UserBundle
Easy Integration:, (*1)
hwi_oauth: https://github.com/hwi/HWIOAuthBundle, (*2)
fosub: https://github.com/FriendsOfSymfony/FOSUserBundle, (*3)
Optional (sonatauser & sonataadmin): https://github.com/sonata-project/SonataUserBundle, (*4)
What it is?
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., (*5)
Installation
From composer, add, (*6)
{
"require": {
"sopinet/userbundle": "dev-master"
}
}
Add bundle to AppKernel (you can need add FOSUB and SonataUserBundle too), (*7)
new Sopinet\UserBundle\SopinetUserBundle(),
Configuration
- 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:, (*8)
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, (*9)
<field name="profilepicture" column="profilepicture" type="string" length="500" nullable="true"></field>
Usage
<a href="{{ hwi_oauth_login_url('google') }}">Connect with Google</a>
<a href="{{ hwi_oauth_login_url('facebook') }}">Connect with Facebook</a>