getFirst("UserModel",array("id"=>$userId));
if (is_null($user)){
GUIHandler::redirect("index.php");
}
$request = GlobalVariables::get("dao")->getFirst("PasswordRecoveryRequestModel",array("id"=>$requestCode,"target.id"=>$userId,"target.class"=>"UserModel"));
if (is_null($request)){
GUIHandler::redirect("index.php");
}
$action = PostHandler::get("action");
if (!is_null($action) && strcmp("", $action)!=0){
if (strcmp("change", $action)==0){
$err = false;
$exc = new GUIException(array());
// Validate Password
$pass = trim(PostHandler::get("password"));
if (strcmp($pass,"")==0){
$err = true;
$exc->addMessage("Inserire una nuova password");
}
if (strcmp($pass,PostHandler::get("password_confirm"))!=0){
$err = true;
$exc->addMessage("Le password inserite non coincidono");
}
$user->password = sha1($pass);
if ($err){
throw $exc;
}
GlobalVariables::get("dao")->delete($request);
GlobalVariables::get("dao")->save($user);
$changed = true;
}
}
}catch(GUIException $ex){
$error = $ex->getMessageMerged("
");
}catch (Exception $exec){
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
}
?>