public function setOpenIdentity(UserIdentitiy $userIdentitiy) { try { $userIdentitiy->save(); $userIdentitiy->refresh(); return $userIdentitiy; } catch (Exception $exc) { echo $exc->getTraceAsString(); } }
/** * * @param string $username * @param array $additionalData * @return bool * @throws AuthenticationServiceException */ public function setOpenIdCredentials($username, $additionalData) { $user = $this->getOpenIdAuthenticationDao()->getOpenIdCredentials($username); if (is_null($user) || !$user) { return false; } else { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); if ($user->getIsAdmin() == 'No' && $user->getEmpNumber() == '') { throw new AuthenticationServiceException('Employee not assigned'); } elseif (!is_null($user->getEmployee()->getTerminationId())) { throw new AuthenticationServiceException('Employee is terminated'); } elseif ($user->getStatus() == 0) { throw new AuthenticationServiceException('Account disabled'); } $identity = $this->getOpenIdentityDao()->getOpenIdentity($user->getId(), $additionalData['providerid']); if (!count($identity) > 0) { $identity = new UserIdentitiy(); $identity->setUserId($user->getId()); $identity->setProviderId($additionalData['providerid']); $identity->setUserIdentity($additionalData['useridentity']); $identity->save(); } if ($identity instanceof UserIdentitiy) { if ($identity->getUserIdentity() != $additionalData['useridentity']) { return false; } } session_regenerate_id(TRUE); $this->setBasicUserAttributes($user); $this->setBasicUserAttributesToSession($user); $this->setRoleBasedUserAttributes($user); $this->setRoleBasedUserAttributesToSession($user); $this->setSystemBasedUserAttributes($user, $additionalData); $this->setSystemBasedUserAttributesToSession($user, $additionalData); $webRoot = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); $this->getCookieManager()->setCookie('Loggedin', 'True', 0, $webRoot); return true; } return true; }