Introduction ¶
EOpenID class extends from CBaseUserIdentity and implements the OpenID protocol to authenticate a user. Based on Mewp's LightOpenID class.
Note: Please post the issues on Github
Download ¶
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/components
Usage ¶
The action:
public function actionOpenIDLogin() {
$openid=new EOpenID;
if(!isset($_GET['openid_mode'])) {
if(isset($_POST['openid_identifier'])) {
$openid->authenticate($_POST['openid_identifier']);
}
}
elseif(isset($_GET['openid_mode'])) {
$openid->validate();
Yii::app()->user->login($openid);
}
$this->render('openIDLogin',array('openid'=>$openid));
}
The view:
<div class="form">
<?php echo CHtml::beginForm(); ?>
<div class="row">
<?php echo CHtml::label('Identifier:', 'openid_identifier'); ?>
<?php echo CHtml::textField('openid_identifier', '', array('size'=>40)); ?>
<p class="hint">
Hint: You may login with <tt>https://www.google.com/accounts/o8/id</tt>.
</p>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Login'); ?>
</div>
<?php echo CHtml::endForm(); ?>
</div><!-- form -->
License ¶
Some time ago I developed this extension for InDaHouseRulez SL. I no longer work there, but I still support the extension.
The extension was released under the MIT license, so I made a fork on GitHub, where you'll find the latest version:
https://github.com/jorgebg/yii-eopenid
Change Log ¶
November 2, 2010 ¶
- Updated to new LightOpenID version 0.3 (thanks hightman)
July 27, 2010 ¶
- Initial release.
July 28, 2010 ¶
- Renamed as EOpenID.
- PHP5 object constructor.
How can I access the getIdentity() in EOpenID class?
I want to get user id (nickname) from views, how can I access that?
It works!
The lightweight OpenID component works! It could be better if the author can offer more samples.
Feedback
This one seems to be really light.
Still, there are some things to improve:
OpenId
superble!
RE: How can I access the getIdentity() in EOpenID class?
Hi.
OpenID can be accessed via:
Nickname could be accessed (but it doesn't work for me) via:
Accesing user name
If I'm not mistaken, you can't access Yii::app()->user->name, because it is not defined by default. In my application I define this property by adding to my base user identity component (UserIdentity.php in protected/components) a getter for it. This way:
public function getName() { return $this->_name; }
I also define in the beginning of UserIdentity class, a private variable used here:
private $_name;
And set it's value in the else part, which is executed if user is properly authenticated:
else { ... $this->_name = $user->NAZW; $this->errorCode = self::ERROR_NONE; }
Only then I can access name of a user from anywhere in the application.
But this was tested only on base UserIdentity class, that extends from CUserIdentity and is generated in every Yii demo application. I did NOT checked this solution with this extension. You'll have to do this yourself.
No server found!
Getting error no server found!while working with it.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.