10 require_once
'EAuthServiceBase.php';
31 protected $requiredAttributes = array();
39 public function init($component, $options = array()) {
41 $this->auth = Yii::app()->loid->load();
50 if (!empty($_REQUEST[
'openid_mode'])) {
51 switch ($_REQUEST[
'openid_mode']) {
54 if ($this->auth->validate()) {
55 $this->attributes[
'id'] = $this->auth->identity;
57 $attributes = $this->auth->getAttributes();
58 foreach ($this->requiredAttributes as $key => $attr) {
59 if (isset($attributes[$attr[1]])) {
60 $this->attributes[$key] = $attributes[$attr[1]];
63 throw new EAuthException(Yii::t(
'eauth',
'Unable to complete the authentication because the required data was not received.', array(
'{provider}' => ucfirst($this->
getServiceName()))));
68 $this->authenticated =
true;
72 throw new EAuthException(Yii::t(
'eauth',
'Unable to complete the authentication because the required data was not received.', array(
'{provider}' => ucfirst($this->
getServiceName()))));
76 catch (Exception $e) {
86 throw new CHttpException(400, Yii::t(
'yii',
'Your request is invalid.'));
91 $this->auth->identity = $this->url;
92 $this->auth->required = array();
93 foreach ($this->requiredAttributes as $attribute)
94 $this->auth->required[$attribute[0]] = $attribute[1];
95 $this->auth->realm = Yii::app()->request->hostInfo;
96 $this->auth->returnUrl = $this->auth->realm.Yii::app()->request->url;
99 $url = $this->auth->authUrl();
100 Yii::app()->request->redirect($url);
102 catch (Exception $e) {