Commit 48d1e3ab765923eba5f0a0611d90477d5b8f5026
1 parent
1c6d5b94
Exists in
master
and in
7 other branches
Correção no login quando o susuário não for master
Showing
4 changed files
with
27 additions
and
14 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/admin.php
... | ... | @@ -194,12 +194,13 @@ Array originada de fetchAll |
194 | 194 | */ |
195 | 195 | function pegaDados($sql,$dbh="",$close=true) |
196 | 196 | { |
197 | + error_reporting(0); | |
197 | 198 | $resultado = array(); |
198 | 199 | //is_string para efeitos de compatibilidade |
199 | 200 | if($dbh == "" || is_string($dbh)){ |
200 | 201 | include(dirname(__FILE__)."/conexao.php"); |
201 | 202 | } |
202 | - //error_reporting(0); | |
203 | + error_reporting(0); | |
203 | 204 | //$dbh deve ser definido com somente leitura, mas por prevencao: |
204 | 205 | $sql = str_ireplace(array("update","delete","insert","--","drop",";"),"",$sql); |
205 | 206 | $q = $dbh->query($sql,PDO::FETCH_ASSOC); | ... | ... |
admin/php/login.php
... | ... | @@ -114,8 +114,8 @@ switch (strtoupper($funcao)) |
114 | 114 | case "LOGIN": |
115 | 115 | $usuario = $_POST["usuario"]; |
116 | 116 | $senha = $_POST["senha"]; |
117 | - | |
118 | 117 | $teste = autenticaUsuario($usuario,$senha); |
118 | + | |
119 | 119 | if($teste == "muitas tentativas"){ |
120 | 120 | logoutUsuario(); |
121 | 121 | header ( "HTTP/1.1 403 Muitas tentativas" ); |
... | ... | @@ -293,8 +293,11 @@ function validaSessao(){ |
293 | 293 | // |
294 | 294 | function autenticaUsuario($usuario,$senha){ |
295 | 295 | include(dirname(__FILE__)."/conexao.php"); |
296 | + error_reporting(0); | |
296 | 297 | $senhamd5 = md5($senha); |
298 | + | |
297 | 299 | $senhaHash = password_hash($senha, PASSWORD_DEFAULT); |
300 | + | |
298 | 301 | //faz um teste de tentativas de acesso |
299 | 302 | $nomeArquivo = $dir_tmp."/a".md5($usuario."testeTentativas").intval(time() / 1000); |
300 | 303 | if(!file_exists($dir_tmp)){ |
... | ... | @@ -347,21 +350,15 @@ function autenticaUsuario($usuario,$senha){ |
347 | 350 | $dados = array(); |
348 | 351 | if(strlen($senha) == 32){ |
349 | 352 | $dados = pegaDados("select id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and senha = '$senhamd5' and ativo = 1",$dbh,false); |
353 | + if(count($dados) == 1 && $dados[0]["senha"] == $senhamd5 && $dados[0]["login"] == $usuario){ | |
354 | + $ok = true; | |
355 | + } | |
350 | 356 | } |
351 | 357 | else{ |
352 | - $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); | |
353 | - } | |
354 | - if(count($dados) > 0){ | |
355 | - $ok = true; | |
356 | - } | |
357 | - //testa tambem com a nova forma de armazenamento de senha usando password_hash | |
358 | - if($ok == false){ | |
359 | 358 | $usuarios = pegaDados("select senha,id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and ativo = 1",$dbh,false); |
360 | - foreach($usuarios as $d){ | |
361 | - if (password_verify($d["senha"], $senhaHash)){ | |
362 | - $ok = true; | |
363 | - $dados = array("id_usuario"=>$d["id_usuario"],"nome_usuario"=>$d["nome_usuario"]); | |
364 | - } | |
359 | + if (count($usuarios) == 1 && password_verify($senha,$usuarios[0]["senha"])){ | |
360 | + $ok = true; | |
361 | + $dados[] = array("id_usuario"=>$usuarios[0]["id_usuario"],"nome_usuario"=>$usuarios[0]["nome_usuario"]); | |
365 | 362 | } |
366 | 363 | $usuarios = null; |
367 | 364 | } | ... | ... |
admin1/dicionario/usuarios.js
... | ... | @@ -43,5 +43,20 @@ i3GEOadmin.usuarios.dicionario = { |
43 | 43 | pt : "Não", |
44 | 44 | en : "", |
45 | 45 | es : "" |
46 | + } ], | |
47 | + 'labelNovaSenha' : [ { | |
48 | + pt : "Nova senha", | |
49 | + en : "", | |
50 | + es : "" | |
51 | + } ], | |
52 | + 'labelDataCadastro' : [ { | |
53 | + pt : "Data do cadastro", | |
54 | + en : "", | |
55 | + es : "" | |
56 | + } ], | |
57 | + 'labelAtivo' : [ { | |
58 | + pt : "Ativo?", | |
59 | + en : "", | |
60 | + es : "" | |
46 | 61 | } ] |
47 | 62 | }; | ... | ... |