Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/mybb-es.com/html/inc/class_language.php on line 201
Iniciar sesion con la direccion de email
Páginas (2): 1 2   
Cluster   16 Oct, 2011, 12:02 pm
#1
Si desea permitir el inicio de sesion de dirección de correo electrónico pero no con el nombre de usuario
En tu inc/functions_user.php busca:
Código PHP:
<?php 
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global
$db;

$query = $db->simple_select("users", "uid,username,password,salt,loginkey,coppauser,usergroup", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

$user = $db->fetch_array($query);
if(!
$user['uid'])
{
return
false;
}
else
{
return
validate_password_from_uid($user['uid'], $password, $user);
}
}

Y cambia por:
Código PHP:
<?php 
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global
$db;

$query = $db->simple_select("users", "uid,username,email,password,salt,loginkey,coppauser,usergroup", "LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

$user = $db->fetch_array($query);
if(!
$user['uid'])
{
return
false;
}
else
{
return
validate_password_from_uid($user['uid'], $password, $user);
}
}


Si quieres permitir iniciar sesión con el nombre de usuario o dirección de correo electrónico
En tu inc/functions_user.php busca:
Código PHP:
<?php 
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global
$db;

$query = $db->simple_select("users", "uid,username,password,salt,loginkey,coppauser,usergroup", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

$user = $db->fetch_array($query);
if(!
$user['uid'])
{
return
false;
}
else
{
return
validate_password_from_uid($user['uid'], $password, $user);
}
}

Y cambia por:
Código PHP:
<?php 
/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global
$db;

$query = $db->simple_select("users", "uid,username,email,password,salt,loginkey,coppauser,usergroup", "LOWER(username)='".$db->escape_string(my_strtolower($username))."' OR LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

$user = $db->fetch_array($query);
if(!
$user['uid'])
{
return
false;
}
else
{
return
validate_password_from_uid($user['uid'], $password, $user);
}
}


Para ambas
En tu inc/functions_user.php busca:
Código PHP:
<?php 
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global
$db;

$query = $db->simple_select("users", "COUNT(*) as user", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

if(
$db->fetch_field($query, 'user') == 1)
{
return
true;
}
else
{
return
false;
}
}

Y cambia por:
Código PHP:
<?php 
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global
$db;

$query = $db->simple_select("users", "COUNT(*) as user,email,username", "LOWER(username)='".$db->escape_string(my_strtolower($username))."' OR LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

if(
$db->fetch_field($query, 'user') == 1)
{
return
true;
}
else
{
return
false;
}
}

Creditos: Dylan M.

:)
Gustavo R.   16 Oct, 2011, 12:37 pm
#2
Espectacular Smile

Muchas gracias por traerlo Dani. Rep+
~ice   16 Oct, 2011, 3:22 pm
#3
cool!
el de ambas esta genial!
Gracias Dano ;D
Jesam   17 Oct, 2011, 7:21 am
#4
Awesome!! Gracias por compartir con todos nosotros.
Omar G.   17 Oct, 2011, 7:41 am
#5
Yo lo probé y no funciono...
Cluster   17 Oct, 2011, 12:55 pm
#6
Cuando realizas el paso 1 "o" 2 es opcional (uno solo de los 2) y el 3ro es para ambas

:)
InfraWorld   17 Oct, 2011, 4:05 pm
#7
Yo utilize este paso..


(16 Oct, 2011, 12:02 pm)Cluster escribió: Para ambas
En tu inc/functions_user.php busca:
Código PHP:
<?php 
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global
$db;

$query = $db->simple_select("users", "COUNT(*) as user", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

if(
$db->fetch_field($query, 'user') == 1)
{
return
true;
}
else
{
return
false;
}
}

Y cambia por:
Código PHP:
<?php 
/**
* Checks if $username already exists in the database.
*
* @param string The username for check for.
* @return boolean True when exists, false when not.
*/
function username_exists($username)
{
global
$db;

$query = $db->simple_select("users", "COUNT(*) as user,email,username", "LOWER(username)='".$db->escape_string(my_strtolower($username))."' OR LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));

if(
$db->fetch_field($query, 'user') == 1)
{
return
true;
}
else
{
return
false;
}
}

Ya que quiero que se pueda Iniciar Sesion tanto con su Correo como con su Nombre de Usuario, pero no me funciona... O estoy utilizando el Equivocado..??

Ignnacio Ausente   17 Oct, 2011, 4:08 pm
#8
Excelente tutorial, +1.
Cluster   17 Oct, 2011, 5:27 pm
#9
Infraworld ocupas usar esa + la segunda

:)
InfraWorld   17 Oct, 2011, 5:52 pm
#10
(17 Oct, 2011, 5:27 pm)Cluster escribió: Infraworld ocupas usar esa + la segunda

Gracias Amigo, Me Funciono Perfecto.. +1Rep.

Páginas (2): 1 2   
  
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.