Files
fdn2/public/mobile/passwordForgotMobile.php
T

98 lines
2.5 KiB
PHP

<?php
/*
Author: Riccardo Di Dato
Creation Date: 16/mar/2016
*/
require_once(dirname(__FILE__)."/../load.php");
try {
$sent = false;
$msg = "";
$action = PostHandler::get("action");
$email = "";
if (!is_null($action) && strcmp($action, "recover")==0){
$email = trim(PostHandler::get("email"));
$user = GlobalVariables::get("dao")->getFirst("UserModel",array("email"=>$email)); // WTF!?!?!
if (is_null($user)){
$msg = "Email non valida";
}
else {
$sent = true;
$oldOne = GlobalVariables::get("dao")->getFirst("PasswordRecoveryRequestModel",array("target.class"=>"UserModel","target.id"=>$user->id));
if (!is_null($oldOne)){
GlobalVariables::get("dao")->delete($oldOne);
}
$request = PasswordRecoveryRequestModel::fromModel($user);
GlobalVariables::get("dao")->save($request);
// $mail = FDN_MailHelper::getUserPasswordResetMail($user);
// GlobalVariables::get("dao")->save($mail);
}
}
}catch(GUIException $ex){
$msg = $ex->getMessage();
$err = true;
}catch (Exception $exec){
$model = LogModel::fromException($exec);
GlobalVariables::get("dao")->save($model);
$msg = "Si è verificato un errore inatteso durante l'operazione. Se il problema persiste contattaci comunicandoci il seguente codice <b>" . $model->getCode() . "</b>";
}
if ($sent){
if (strcmp("", $msg)!=0){
?>
<div style="color:red; text-align:center;"><?php echo $msg;?></div>
<?php
}
else {
?>
<div style="padding:2em;">A breve riceverai una email per modificare la password!</div>
<?php
}
}
else {
?>
<div class="modalBody">
<div class="title">Inserisci la tua email per recuperare i dati</div>
<div style="color:red; text-align:center;"><?php echo $msg;?></div>
<form id="recForm">
<input type="hidden" name="action" value=""/>
<div><input placeholder="EMAIL" type="text" name="email" value="<?php echo $email; ?>"/></div>
<div class="btn"><a class="btn" id="recoverBtn" href="javascript:void(0);">Richiedi</a></div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#recoverBtn").click(function () {
$("#recForm input[name=action]").val("recover");
$.ajax({
method:"POST",
url:'passwordForgotMobile.php',
data:$("#recForm").serialize(),
success: function(data){
$(".loginData").html(data);
}
});
});
$('#recForm input[name=email]').keypress(function(event) {
if (event.which==13){
$("#recoverBtn").click();
return false;
}
});
});
</script>
<?php
}
?>