Commit e7c2fcbc33535225f829d631fef569ae91c812e4
1 parent
61ff58c3
Exists in
master
Inclusão de verificação de tentativas de login, máximo de 3 última hora
Showing
4 changed files
with
27 additions
and
3 deletions
Show diff stats
admin/php/login.php
@@ -115,6 +115,11 @@ switch (strtoupper($funcao)) | @@ -115,6 +115,11 @@ switch (strtoupper($funcao)) | ||
115 | $senha = $_POST["senha"]; | 115 | $senha = $_POST["senha"]; |
116 | 116 | ||
117 | $teste = autenticaUsuario($usuario,$senha); | 117 | $teste = autenticaUsuario($usuario,$senha); |
118 | + if($teste == "muitas tentativas"){ | ||
119 | + logoutUsuario(); | ||
120 | + header ( "HTTP/1.1 403 Muitas tentativas" ); | ||
121 | + exit; | ||
122 | + } | ||
118 | if($teste != false){ | 123 | if($teste != false){ |
119 | $_SESSION["usuario"] = $usuario; | 124 | $_SESSION["usuario"] = $usuario; |
120 | $_SESSION["id_usuario"] = $teste["usuario"]["id_usuario"]; | 125 | $_SESSION["id_usuario"] = $teste["usuario"]["id_usuario"]; |
@@ -290,11 +295,26 @@ function autenticaUsuario($usuario,$senha){ | @@ -290,11 +295,26 @@ function autenticaUsuario($usuario,$senha){ | ||
290 | include(dirname(__FILE__)."/conexao.php"); | 295 | include(dirname(__FILE__)."/conexao.php"); |
291 | $senhamd5 = md5($senha); | 296 | $senhamd5 = md5($senha); |
292 | $senhaHash = password_hash($senha, PASSWORD_DEFAULT); | 297 | $senhaHash = password_hash($senha, PASSWORD_DEFAULT); |
298 | + //faz um teste de tentativas de acesso | ||
299 | + $nomeArquivo = $dir_tmp."/a".md5($usuario."testeTentativas").intval(time() / 1000); | ||
300 | + if(!file_exists($dir_tmp)){ | ||
301 | + return false; | ||
302 | + } | ||
303 | + if(file_exists($nomeArquivo)){ | ||
304 | + $tentativas = (int) file_get_contents($nomeArquivo); | ||
305 | + if($tentativas > 3){ | ||
306 | + return "muitas tentativas"; | ||
307 | + } | ||
308 | + $tentativas = $tentativas + 1; | ||
309 | + file_put_contents($nomeArquivo, $tentativas); | ||
310 | + } | ||
311 | + else { | ||
312 | + file_put_contents($nomeArquivo, 1); | ||
313 | + } | ||
293 | //verifica se o usuario esta cadastrado no ms_configura.php em $i3geomaster | 314 | //verifica se o usuario esta cadastrado no ms_configura.php em $i3geomaster |
294 | //echo "select * from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and (senha = '$senhamd5' or senha = '$senha') and ativo = 1";exit; | 315 | //echo "select * from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and (senha = '$senhamd5' or senha = '$senha') and ativo = 1";exit; |
295 | //exit; | 316 | //exit; |
296 | if(verificaMaster($usuario,$senha) == true){ | 317 | if(verificaMaster($usuario,$senha) == true){ |
297 | - | ||
298 | $pa = pegaDados("select * from ".$esquemaadmin."i3geousr_papelusuario ",$dbh,false); | 318 | $pa = pegaDados("select * from ".$esquemaadmin."i3geousr_papelusuario ",$dbh,false); |
299 | $op = pegadados("SELECT O.codigo FROM ".$esquemaadmin."i3geousr_operacoes AS O",$dbh,false); | 319 | $op = pegadados("SELECT O.codigo FROM ".$esquemaadmin."i3geousr_operacoes AS O",$dbh,false); |
300 | $gr = pegadados("SELECT * from ".$esquemaadmin."i3geousr_grupos ",$dbh,false); | 320 | $gr = pegadados("SELECT * from ".$esquemaadmin."i3geousr_grupos ",$dbh,false); |
@@ -317,6 +337,7 @@ function autenticaUsuario($usuario,$senha){ | @@ -317,6 +337,7 @@ function autenticaUsuario($usuario,$senha){ | ||
317 | $r = array("usuario"=>$master,"papeis"=>$papeis,"operacoes"=>$operacoes,"gruposusr"=>$gruposusr); | 337 | $r = array("usuario"=>$master,"papeis"=>$papeis,"operacoes"=>$operacoes,"gruposusr"=>$gruposusr); |
318 | $dbh = null; | 338 | $dbh = null; |
319 | $dbhw = null; | 339 | $dbhw = null; |
340 | + file_put_contents($nomeArquivo, 1); | ||
320 | return $r; | 341 | return $r; |
321 | } | 342 | } |
322 | else{ | 343 | else{ |
@@ -362,6 +383,7 @@ function autenticaUsuario($usuario,$senha){ | @@ -362,6 +383,7 @@ function autenticaUsuario($usuario,$senha){ | ||
362 | $r = array("usuario"=>$dados[0],"papeis"=>$papeis,"operacoes"=>$operacoes,"gruposusr"=>$gruposusr); | 383 | $r = array("usuario"=>$dados[0],"papeis"=>$papeis,"operacoes"=>$operacoes,"gruposusr"=>$gruposusr); |
363 | $dbh = null; | 384 | $dbh = null; |
364 | $dbhw = null; | 385 | $dbhw = null; |
386 | + file_put_contents($nomeArquivo, 1); | ||
365 | return $r; | 387 | return $r; |
366 | } | 388 | } |
367 | else{ | 389 | else{ |
ferramentas/loginusuario/dicionario.js
1 | //+$trad(1,i3GEOF.loginusuario.dicionario)+ | 1 | //+$trad(1,i3GEOF.loginusuario.dicionario)+ |
2 | i3GEOF.loginusuario.dicionario = { | 2 | i3GEOF.loginusuario.dicionario = { |
3 | - 1 : [ { | ||
4 | - pt : "", | 3 | + "tentativas" : [ { |
4 | + pt : "Após 3 tentativas, tente mais tarde", | ||
5 | en : "", | 5 | en : "", |
6 | es : "" | 6 | es : "" |
7 | } ] | 7 | } ] |
ferramentas/loginusuario/template_mst.html
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | <p class='paragrafo'> | 2 | <p class='paragrafo'> |
3 | {{{ativo}}}: <b><i>{{{usuarioLogado}}}</i></b> | 3 | {{{ativo}}}: <b><i>{{{usuarioLogado}}}</i></b> |
4 | <p class='paragrafo'>{{{usuario}}}:</p> | 4 | <p class='paragrafo'>{{{usuario}}}:</p> |
5 | + <p class="paragrafo">{{{tentativas}}}</p> | ||
5 | <div class='i3geoForm i3geoFormIconeUsuario'> | 6 | <div class='i3geoForm i3geoFormIconeUsuario'> |
6 | <input id=i3geousuario type=text value=''/> | 7 | <input id=i3geousuario type=text value=''/> |
7 | </div> | 8 | </div> |
ferramentas/loginusuario/template_mst_bt.html
@@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
34 | <div class="row"> | 34 | <div class="row"> |
35 | <div class="col-md-12"> | 35 | <div class="col-md-12"> |
36 | <h6 class="text-muted">{{{ativo}}}: {{{usuarioLogado}}}</h6> | 36 | <h6 class="text-muted">{{{ativo}}}: {{{usuarioLogado}}}</h6> |
37 | + <h6 class="text-info">{{{tentativas}}}</h6> | ||
37 | </div> | 38 | </div> |
38 | </div> | 39 | </div> |
39 | </li> | 40 | </li> |
40 | \ No newline at end of file | 41 | \ No newline at end of file |