-
Notifications
You must be signed in to change notification settings - Fork 0
/
password_reset.php
executable file
·40 lines (34 loc) · 1.49 KB
/
password_reset.php
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
<?php
require_once 'bootstrap.php';
if(isset($_POST["email"])){
if(isPresentEmail($_POST["email"],$dbh->getAllEmails())){
$code = generateRandomCode();
$hashed_code = password_hash($code, PASSWORD_DEFAULT);
$dbh->insertPwdToken($_POST["email"],$hashed_code);
$templateParams["email"] = $_POST["email"];
sendEMail($templateParams["email"],"Reset Password","Il Codice per cambiare la password è : ".$code);
$templateParams["pagina"]='inserimento_codice.php';
}else{
$templateParams["pagina"]='password_reset_template.php';
$templateParams["erroreEmail"]="L'email inserita non è presente nel sito!";
}
}else{
$templateParams["pagina"]='password_reset_template.php';
}
if(isset($_POST["code"])){
if(password_verify($_POST["code"],$dbh->getTokenByEmail($_POST["confirmed_email"]))){
$templateParams["pagina"]='new_password_template.php';
$templateParams["email"] = $_POST["confirmed_email"];
}
}
if(isset($_POST["pass_1"]) && isset($_POST["pass_2"])){
var_dump($_POST);
$dbh->changePwd($_POST["confirmed_email"], password_hash($_POST["pass_1"], PASSWORD_DEFAULT));
header("location: login.php");
}
$templateParams["titolo"]='LaBottega - Reset password';
$templateParams["categorie"] = $dbh->getCategories();
$templateParams["sottoCategorie"] = $dbh->getSubCategories();
$templateParams["js"] = JS_ROOT.'subscribe-validator.js';
require 'template/base.php';
?>