login with email address instead of username

15 years 11 months ago #64261 by jmaduk
are previous 1.1 thread included a cblogin hack that allowed the user to login with their email address and password instead of username and password...

Beat mentioned in the post that it might be added to the new version... Was it?

I didn't see a specific mention in the 1.2 features thread

www.MySmallBizU.com
1000 Videos, Hosting, Software, Support,
Coaching and Community!

Please Log in to join the conversation.

15 years 11 months ago #64262 by exrace
I don't recall seeing this as an option but that would be a great option. Only bad thing about that if you used the field in users lists and it exposed the users e-mail address for all to see.

Support the devs!

Please Log in to join the conversation.

15 years 11 months ago #64269 by bertm
The hack had nothing to do with using email address as username, but rather to look at the login entry field to determine if it is in the form of an email address. If so, then do a search for userID based on email address, then stuff the login fields appropriately.

Here is the original hack

www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,42/id,50714/#50714

I have looked at the backend of Cb1.2 and have not seen controls for this feature. Making it work in J1.5 is a little complicated and that might have made it not worthwhile to include in CB1.2. Perhaps when the code settles down a few of us might compare notes on re-integrating it for J1.0.

I saw where someone had taken the idea and built a module or CB plugin for this feature and was charging a few bucks for it.

Please Log in to join the conversation.

15 years 11 months ago #65415 by nhudell

I saw where someone had taken the idea and built a module or CB plugin for this feature and was charging a few bucks for it.


That's not cool!

I really hope this feature is available soon, it's a brilliant thing to use a website and never have to remember what your username is.

The relly big advantage is that you have hardly anyone forget their login details, it's so great. ;)

Please Log in to join the conversation.

15 years 11 months ago #65423 by exrace
Well in Joomla 1.5 you could build an auth plugin the extends the CB plugin to allow this.

Can you PM me the place you saw this module being sold?
I don't want to give that person a free link in these forums. Curious how they implemented it.

Post edited by: exrace, at: 2008/06/12 13:08

Support the devs!

Please Log in to join the conversation.

15 years 11 months ago #65533 by beubeu2k
I have a solution for Joomla 1.5 and CB 1.2.

First you create a new function in "administrator/components/com_comprofiler/library/cb/cb.tables"

Just after the loadByUsername() one.

[code:1]/**
* Loads user email from database
*
* @param string $username
* @return boolean TRUE: success, FALSE: error in database access
*/
function loadByEmail( $email ) {
if ( $email == null ) {
return false;
}
//BB fix : resets default values to all object variables, because NULL SQL fields do not overide existing variables !
//Note: Prior to PHP 4.2.0, Uninitialized class variables will not be reported by get_class_vars().
$class_vars = get_class_vars(get_class($this));
foreach ($class_vars as $name => $value) {
if ( ($name != $this->_tbl_key) and ($name != "_db"«») and ($name != "_tbl"«») and ($name != "_tbl_key"«») ) {
$this->$name = $value;
}
}
$this->reset();
//end of BB fix.
$query = 'SELECT *'
. "\n FROM " . $this->_cmsUserTable . ' AS u'
. "\n LEFT JOIN " . $this->_tbl . ' AS c ON c.' . $this->_tbl_key . ' = u.' . $this->_cmsUserTableKey
. " WHERE u." . $this->_cmsUserTableEmail . ' = ' . $this->_db->Quote( $email )
;
$this->_db->setQuery( $query );

$arr = $this->_db->loadAssoc( );

if ( $arr ) {
foreach ( $arr as $k => $v ) {
$this->$k = $v;
}
return true;
} else {
return false;
}
}[/code:1]

After you find (Aroud line 1480) :
[code:1] if ( $row->loadByUsername( stripslashes( $username ) ) && cbHashPassword( $passwd2, $row ) ) {[/code:1]

You replace it by :
[code:1]if ( $row->loadByEmail( stripslashes( $username ) ) && cbHashPassword( $passwd2, $row ) ) {[/code:1]

After you find (Aroud line 1542) :
[code:1]$_CB_framework->login( $username, $passwd2, $rememberMe );[/code:1]

You replace it by :
[code:1]$_CB_framework->login( $row->username, $passwd2, $rememberMe );[/code:1]

After that you can login only with email. It's working for me but I'am not sure it's well secure.

Is it working for you ?

Post edited by: beubeu2k, at: 2008/06/13 14:34

Post edited by: beubeu2k, at: 2008/06/13 14:35

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.246 seconds

Facebook Twitter LinkedIn