X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fcurrent_user.inc;h=cc75e5e87cbef51969b18c35921f667b09200c7e;hb=7010ff2972dfbc8be4e577bdeac6b8da7278b691;hp=76d52f2f126f5228c4b74e6a1d2e406de14e4106;hpb=08c6b6eb6affc0b42cd47165bd475c6ce1a2c8dc;p=fa-stable.git diff --git a/includes/current_user.inc b/includes/current_user.inc index 76d52f2f..cc75e5e8 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -54,7 +54,7 @@ class current_user function set_company($company) { - $this->company = $company; + $this->company = (int)$company; } function login($company, $loginname, $password) @@ -131,6 +131,32 @@ class current_user return $this->logged; } + function reset_password($company, $email) { + global $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;