Commit 61ff58c3da7c35ec4b485252d248120c028da243
1 parent
4b1860b0
Exists in
master
Substituição da função md5 por função específica do php para tratamento de senhas
Showing
2 changed files
with
28 additions
and
4 deletions
Show diff stats
admin/php/login.php
| ... | ... | @@ -289,6 +289,7 @@ function validaSessao(){ |
| 289 | 289 | function autenticaUsuario($usuario,$senha){ |
| 290 | 290 | include(dirname(__FILE__)."/conexao.php"); |
| 291 | 291 | $senhamd5 = md5($senha); |
| 292 | + $senhaHash = password_hash($senha, PASSWORD_DEFAULT); | |
| 292 | 293 | //verifica se o usuario esta cadastrado no ms_configura.php em $i3geomaster |
| 293 | 294 | //echo "select * from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and (senha = '$senhamd5' or senha = '$senha') and ativo = 1";exit; |
| 294 | 295 | //exit; |
| ... | ... | @@ -320,13 +321,29 @@ function autenticaUsuario($usuario,$senha){ |
| 320 | 321 | } |
| 321 | 322 | else{ |
| 322 | 323 | //verifica se a senha e uma string ou pode ser um md5 |
| 324 | + $ok = false; | |
| 325 | + $dados = array(); | |
| 323 | 326 | if(strlen($senha) == 32){ |
| 324 | - $dados = pegaDados("select * from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and senha = '$senhamd5' and ativo = 1",$dbh,false); | |
| 327 | + $dados = pegaDados("select id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and senha = '$senhamd5' and ativo = 1",$dbh,false); | |
| 325 | 328 | } |
| 326 | 329 | else{ |
| 327 | - $dados = pegaDados("select * from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and (senha = '$senhamd5' or senha = '$senha') and ativo = 1",$dbh,false); | |
| 330 | + $dados = pegaDados("select id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and (senha = '$senhamd5' or senha = '$senha') and ativo = 1",$dbh,false); | |
| 328 | 331 | } |
| 329 | 332 | if(count($dados) > 0){ |
| 333 | + $ok = true; | |
| 334 | + } | |
| 335 | + //testa tambem com a nova forma de armazenamento de senha usando password_hash | |
| 336 | + if($ok == false){ | |
| 337 | + $usuarios = pegaDados("select senha,id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and ativo = 1",$dbh,false); | |
| 338 | + foreach($usuarios as $d){ | |
| 339 | + if (password_verify($d["senha"], $senhaHash)){ | |
| 340 | + $ok = true; | |
| 341 | + $dados = array("id_usuario"=>$d["id_usuario"],"nome_usuario"=>$d["nome_usuario"]); | |
| 342 | + } | |
| 343 | + } | |
| 344 | + $usuarios = null; | |
| 345 | + } | |
| 346 | + if($ok == true){ | |
| 330 | 347 | $pa = pegaDados("select * from ".$esquemaadmin."i3geousr_papelusuario where id_usuario = ".$dados[0]["id_usuario"],$dbh,false); |
| 331 | 348 | $op = pegadados("SELECT O.codigo, PU.id_usuario FROM ".$esquemaadmin."i3geousr_operacoes AS O JOIN ".$esquemaadmin."i3geousr_operacoespapeis AS OP ON O.id_operacao = OP.id_operacao JOIN ".$esquemaadmin."i3geousr_papelusuario AS PU ON OP.id_papel = PU.id_papel WHERE id_usuario = ".$dados[0]["id_usuario"],$dbh,false); |
| 332 | 349 | $gr = pegadados("SELECT * from ".$esquemaadmin."i3geousr_grupousuario where id_usuario = ".$dados[0]["id_usuario"],$dbh,false); | ... | ... |
admin/php/usuarios.php
| ... | ... | @@ -65,7 +65,13 @@ error_reporting(0); |
| 65 | 65 | include_once(dirname(__FILE__)."/login.php"); |
| 66 | 66 | $funcoesEdicao = array( |
| 67 | 67 | "ALTERARUSUARIOS", |
| 68 | - "EXCLUIRUSUARIO" | |
| 68 | + "EXCLUIRUSUARIO", | |
| 69 | + "EXCLUIRPAPELUSUARIO", | |
| 70 | + "PEGADADOSUSUARIO", | |
| 71 | + "PEGAUSUARIOS", | |
| 72 | + "PEGAPAPEISUSUARIO", | |
| 73 | + "ENVIARSENHAEMAIL", | |
| 74 | + "LISTAPAPEIS" | |
| 69 | 75 | ); |
| 70 | 76 | if(in_array(strtoupper($funcao),$funcoesEdicao)){ |
| 71 | 77 | if(verificaOperacaoSessao("admin/html/usuarios") == false){ |
| ... | ... | @@ -180,7 +186,8 @@ function alterarUsuarios() |
| 180 | 186 | ); |
| 181 | 187 | //se a senha foi enviada, ela sera trocada |
| 182 | 188 | if($_GET["senha"] != ""){ |
| 183 | - $dataCol["senha"] = md5($_GET["senha"]); | |
| 189 | + //$dataCol["senha"] = md5($_GET["senha"]); | |
| 190 | + $dataCol["senha"] = password_hash($_GET["senha"], PASSWORD_DEFAULT); | |
| 184 | 191 | } |
| 185 | 192 | i3GeoAdminUpdate($dbhw,"i3geousr_usuarios",$dataCol,"WHERE id_usuario = $id_usuario"); |
| 186 | 193 | $retorna = $id_usuario; | ... | ... |