X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fcurrent_user.inc;h=31f53ae6c411d79d26eb451cbf4024c8f6237c3d;hb=aa7eb75a2b21809008113779e9b6c5fa7a869c9b;hp=7c7592e8139fa4da2c06e21941ae30305635c2d8;hpb=a5dcd87f46080a624b1a9ad4b0dd035bbd24ac50;p=fa-stable.git diff --git a/includes/current_user.inc b/includes/current_user.inc index 7c7592e8..31f53ae6 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -131,6 +131,32 @@ class current_user return $this->logged; } + function reset_password($company, $email) { + global $path_to_root, $app_title; + + $this->set_company($company); + $this->logged = false; + + set_global_connection(); + + $myrow = get_user_by_email($email); + + if ($myrow['id'] != "") { + + $bytes = openssl_random_pseudo_bytes(8, $cstrong); + $password = base64_encode($bytes); + + $hash = md5($password); + + update_user_password($myrow['id'], $myrow['user_id'], $hash); + + mail($myrow['email'], _("New password for")." ".$app_title, $password); + + return true; + } + return false; + } + function check_user_access() { global $security_groups;