Añadida LOGIN a través de BASE DE DATOS

Se ha creado la base de datos de usuarios y toda la lógica para iniciar sesión mediante ella.
This commit is contained in:
Fernando Méndez 2021-04-07 20:17:46 +02:00 committed by GitHub
parent 7e2ef23349
commit fad708b963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,24 +68,29 @@ class FormLogin extends Form {
$bd = new UserDAO('complucine');
if($bd){
$selectUser = $bd->selectUser($username);
$selectUser->data_seek(0);
while ($fila = $selectUser->fetch_assoc()) {
if($username === $fila['username'] && $bd->verifyPass($password, $fila['passwd'])){
$this->user = $bd->loadUser($fila['id'], $fila['username'], $fila['email'], $fila['passwd'], $fila['rol']);
$this->user = $bd->loadUser($fila['id'], $fila['username'], $fila['email'], $fila['passwd'], $fila['rol']);
}
}
try{
if ($this->user) {
$_SESSION['user'] = $this->user;
$_SESSION["nombre"] = $this->user->getName();
$_SESSION["login"] = $login;
$_SESSION["rol"] = $this->user->getRol();
}
}
catch (Exception $e){
$_SESSION["login"] = $login;
}
mysqli_free_result($selectUser);
//$selectUser->free();
}
if ($this->user->getName()) {
$_SESSION['user'] = $this->user;
$_SESSION["nombre"] = $this->user->getName();
$_SESSION["login"] = $login;
$_SESSION["rol"] = $this->user->getRol();
}
}
}