Closed symfonyluxury closed 12 years ago
it is not clear for me what you mean. Could you provide more info(your config, code) and so on.
I follow this link" https://github.com/formapro/FpOpenIdBundle/blob/master/Resources/doc/index.md", and everything is fine, when I call $this->get('security.context')->getToken()->getUser() this method, it just returns something like "https://www.google.com/accounts/o8/id?id=AIt********HZhFtKmlkjQ",but I want more details about logged in user, such as email....
try this:
<?php
var_dump($this->get('security.context')->getToken()->getAttributes());
it works! thanks a lot! Moreover, I followed the doc "Configure User Manager\Provider" to generate the user in db , consent the google prompt then comes some errors: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.identity' in 'field list' I have the same config settings to doc, and have my own user entity as well,but there is no map infos in it, is this reason?
have you run: ./console doctrine:schema:update
Implemented, a new field "attributes" generated in table "openid_identities", and seems I should writes somes codes in OpenIdUserManager, but I have not idea how to write the user creation logic there, could you offer me some general sample codes to hint me? Forgive me noob :(
I wrote it by heart. It could contains errors or misspelling so use it as a reference.
<?php
class OpenIdUserManager extends UserManager
{
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function createUserFromIdentity($identity, array $attributes = array())
{
$user = new User();
$user->setUsername(isset($attributes['email']) ? $attributes['email'] : '');
$this->em->persist($user);
$this->em->flush();
return $user;
}
}
followed ur codes,unfortunately, I got this error:
ErrorException: OpenIdUserManager::__construct() must be an instance of Doctrine\ORM\EntityManager, instance of Fp\OpenIdBundle\Entity\IdentityManager given, called in.......
then I use like this: public function __construct(EntityManager $em, IdentityManager $identityManager) and still return the same errors(btw I loaded the relative classes previously,and bundle version is "dev-master")
you have to add your OpenIdUserManager
to service container and pass all required arguments as services from the DI container.
Oh nice! it works by adding entitymanager service, and everything works perfectly as my expectation, thx a lot, you are amazing :)
according to default config settings(namePerson provieded to optional attrubute), it works fine, but always return the string like " https://www.google.com/accounts/o8/id?id=AItOaw**", any ways to access user's attributes?