ModelsAuth.php
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class ModelsAuth {
private $dados;
private $result;
private $msg;
private $rowCount;
const ENTITY = "users";
public function autenticar(array $dados) {
$this->dados = $dados;
$this->validar();
if ($this->result){
$visulizar = new ModelsRead();
$visulizar->exeRead(self::ENTITY, 'WHERE email =:email AND password =:password LIMIT :limit',
"email={$this->dados['email']}&password={$this->dados['password']}&limit=1");
if ($visulizar->getRowCount() == 1) {
//var_dump($Visulizar->getResultado());
$this->result = $visulizar->getResult();
}else {
$this->result = false;
$this->msg = "
<div class='alert alert-danger' role='alert'>
Login e/ou senhas incorretos!
</div>
";
}
}
}
public function validar()
{
$this->dados = array_map('strip_tags', $this->dados);
$this->dados = array_map('trim', $this->dados);
if (in_array('', $this->dados)){
$this->result = false;
$this->msg = "
<div class='alert alert-danger' role='alert'>
Login e/ou senhas incorretos!
</div>
";
}else{
$this->dados['password'] = md5($this->dados['password']);
$this->result = true;
}
}
function getResult() {
return $this->result;
}
function getMsg() {
return $this->msg;
}
function getRowCount() {
return $this->rowCount;
}
}