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,12 +194,13 @@ Array originada de fetchAll | ||
194 | */ | 194 | */ |
195 | function pegaDados($sql,$dbh="",$close=true) | 195 | function pegaDados($sql,$dbh="",$close=true) |
196 | { | 196 | { |
197 | + error_reporting(0); | ||
197 | $resultado = array(); | 198 | $resultado = array(); |
198 | //is_string para efeitos de compatibilidade | 199 | //is_string para efeitos de compatibilidade |
199 | if($dbh == "" || is_string($dbh)){ | 200 | if($dbh == "" || is_string($dbh)){ |
200 | include(dirname(__FILE__)."/conexao.php"); | 201 | include(dirname(__FILE__)."/conexao.php"); |
201 | } | 202 | } |
202 | - //error_reporting(0); | 203 | + error_reporting(0); |
203 | //$dbh deve ser definido com somente leitura, mas por prevencao: | 204 | //$dbh deve ser definido com somente leitura, mas por prevencao: |
204 | $sql = str_ireplace(array("update","delete","insert","--","drop",";"),"",$sql); | 205 | $sql = str_ireplace(array("update","delete","insert","--","drop",";"),"",$sql); |
205 | $q = $dbh->query($sql,PDO::FETCH_ASSOC); | 206 | $q = $dbh->query($sql,PDO::FETCH_ASSOC); |
admin/php/login.php
@@ -114,8 +114,8 @@ switch (strtoupper($funcao)) | @@ -114,8 +114,8 @@ switch (strtoupper($funcao)) | ||
114 | case "LOGIN": | 114 | case "LOGIN": |
115 | $usuario = $_POST["usuario"]; | 115 | $usuario = $_POST["usuario"]; |
116 | $senha = $_POST["senha"]; | 116 | $senha = $_POST["senha"]; |
117 | - | ||
118 | $teste = autenticaUsuario($usuario,$senha); | 117 | $teste = autenticaUsuario($usuario,$senha); |
118 | + | ||
119 | if($teste == "muitas tentativas"){ | 119 | if($teste == "muitas tentativas"){ |
120 | logoutUsuario(); | 120 | logoutUsuario(); |
121 | header ( "HTTP/1.1 403 Muitas tentativas" ); | 121 | header ( "HTTP/1.1 403 Muitas tentativas" ); |
@@ -293,8 +293,11 @@ function validaSessao(){ | @@ -293,8 +293,11 @@ function validaSessao(){ | ||
293 | // | 293 | // |
294 | function autenticaUsuario($usuario,$senha){ | 294 | function autenticaUsuario($usuario,$senha){ |
295 | include(dirname(__FILE__)."/conexao.php"); | 295 | include(dirname(__FILE__)."/conexao.php"); |
296 | + error_reporting(0); | ||
296 | $senhamd5 = md5($senha); | 297 | $senhamd5 = md5($senha); |
298 | + | ||
297 | $senhaHash = password_hash($senha, PASSWORD_DEFAULT); | 299 | $senhaHash = password_hash($senha, PASSWORD_DEFAULT); |
300 | + | ||
298 | //faz um teste de tentativas de acesso | 301 | //faz um teste de tentativas de acesso |
299 | $nomeArquivo = $dir_tmp."/a".md5($usuario."testeTentativas").intval(time() / 1000); | 302 | $nomeArquivo = $dir_tmp."/a".md5($usuario."testeTentativas").intval(time() / 1000); |
300 | if(!file_exists($dir_tmp)){ | 303 | if(!file_exists($dir_tmp)){ |
@@ -347,21 +350,15 @@ function autenticaUsuario($usuario,$senha){ | @@ -347,21 +350,15 @@ function autenticaUsuario($usuario,$senha){ | ||
347 | $dados = array(); | 350 | $dados = array(); |
348 | if(strlen($senha) == 32){ | 351 | if(strlen($senha) == 32){ |
349 | $dados = pegaDados("select id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and senha = '$senhamd5' and ativo = 1",$dbh,false); | 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 | else{ | 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 | $usuarios = pegaDados("select senha,id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and ativo = 1",$dbh,false); | 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 | $usuarios = null; | 363 | $usuarios = null; |
367 | } | 364 | } |
admin1/dicionario/usuarios.js
@@ -43,5 +43,20 @@ i3GEOadmin.usuarios.dicionario = { | @@ -43,5 +43,20 @@ i3GEOadmin.usuarios.dicionario = { | ||
43 | pt : "Não", | 43 | pt : "Não", |
44 | en : "", | 44 | en : "", |
45 | es : "" | 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 | }; |