31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
50$langs->loadLangs(array(
'users',
'companies',
'ldap',
'other'));
54 header(
"Location: ".DOL_URL_ROOT.
'/');
58$action =
GETPOST(
'action',
'aZ09');
59$mode = $dolibarr_main_authentication;
64$username =
GETPOST(
'username',
'alphanohtml');
65$passworduidhash =
GETPOST(
'passworduidhash',
'alpha');
66$setnewpassword =
GETPOST(
'setnewpassword',
'aZ09');
71$hookmanager->initHooks(array(
'passwordforgottenpage'));
74if (
GETPOST(
'dol_hide_leftmenu',
'alpha') || !empty($_SESSION[
'dol_hide_leftmenu'])) {
75 $conf->dol_hide_leftmenu = 1;
77if (
GETPOST(
'dol_hide_topmenu',
'alpha') || !empty($_SESSION[
'dol_hide_topmenu'])) {
78 $conf->dol_hide_topmenu = 1;
80if (
GETPOST(
'dol_optimize_smallscreen',
'alpha') || !empty($_SESSION[
'dol_optimize_smallscreen'])) {
81 $conf->dol_optimize_smallscreen = 1;
83if (
GETPOST(
'dol_no_mouse_hover',
'alpha') || !empty($_SESSION[
'dol_no_mouse_hover'])) {
84 $conf->dol_no_mouse_hover = 1;
86if (
GETPOST(
'dol_use_jmobile',
'alpha') || !empty($_SESSION[
'dol_use_jmobile'])) {
87 $conf->dol_use_jmobile = 1;
95$parameters = array(
'username' => $username);
96$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
98 $message = $hookmanager->error;
103if (empty($reshook)) {
105 if ($action ==
'validatenewpassword' && $username && $passworduidhash) {
106 $edituser =
new User($db);
107 $result = $edituser->fetch(0, $username,
'', 0,
$conf->entity);
109 $message =
'<div class="error">'.dol_escape_htmltag($langs->trans(
"ErrorTechnicalError")).
'</div>';
114 if ($edituser->pass_temp &&
dol_verifyHash($edituser->pass_temp.
'-'.$edituser->id.
'-'.
$conf->file->instance_unique_id, $passworduidhash)) {
116 unset($_SESSION[
'dol_login']);
117 $_SESSION[
'dol_loginmesg'] =
'<!-- warning -->'.$langs->transnoentitiesnoconv(
'NewPasswordValidated');
119 $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0);
120 dol_syslog(
"passwordforgotten.php new password for user->id=".$edituser->id.
" validated in database");
122 header(
"Location: ".DOL_URL_ROOT.
'/?username='.urlencode($edituser->login));
125 $langs->load(
"errors");
126 $message =
'<div class="error">'.$langs->trans(
"ErrorFailedToValidatePasswordReset").
'</div>';
132 if ($action ==
'buildnewpassword' && $username) {
133 $sessionkey =
'dol_antispam_value';
134 $ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) === strtolower(
GETPOST(
'code'))));
135 unset($_SESSION[$sessionkey]);
139 dol_syslog(
'Bad value for code, password reset refused', LOG_NOTICE);
141 $langs->load(
'errors');
142 $message =
'<div class="error">'.$langs->trans(
"ErrorBadValueForCode").
'</div>';
144 $isanemail = preg_match(
'/@/', $username);
146 $edituser =
new User($db);
147 $result = $edituser->fetch(0, $username,
'', 1,
$conf->entity);
148 if ($result == 0 && $isanemail) {
149 $result = $edituser->fetch(0,
'',
'', 1,
$conf->entity, $username);
154 $edituser->loadRights(
'user');
155 if (!$edituser->hasRight(
'user',
'self',
'password')) {
157 $edituser->error =
'USERNOTALLOWEDTOCHANGEPASS';
162 $messagewarning =
'<div class="warning paddingtopbottom'.(!
getDolGlobalString(
'MAIN_LOGIN_BACKGROUND') ?
'' :
' backgroundsemitransparent boxshadow').
'">';
164 $messagewarning .= $langs->trans(
"IfLoginExistPasswordRequestSent");
166 $messagewarning .= $langs->trans(
"IfEmailExistPasswordRequestSent");
168 $messagewarning .=
'</div>';
170 if ($result <= 0 && ($edituser->error ==
'USERNOTFOUND' || $edituser->error ==
'USERNOTALLOWEDTOCHANGEPASS')) {
172 $message .= $messagewarning;
175 if (empty($edituser->email)) {
177 $message .= $messagewarning;
179 $newpassword = $edituser->setPassword($user,
'', 1);
180 if (is_int($newpassword) && $newpassword < 0) {
182 $langs->load(
'errors');
183 $message =
'<div class="error">'.$langs->trans(
"ErrorFailedToChangePassword").
'</div>';
186 if ($edituser->send_password($user, $newpassword, 1) > 0) {
187 $message .= $messagewarning;
191 $message .=
'<div class="error">'.$edituser->error.
'</div>';
205$dol_url_root = DOL_URL_ROOT;
207$appli = constant(
'DOL_APPLICATION_TITLE');
210 $appli = (preg_match(
'/^\+/', $applicustom) ? $appli :
'').$applicustom;
212 $appli .=
" ".DOL_VERSION;
220if (!empty(
$conf->modules_parts[
'tpl'])) {
221 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array(
'/core/tpl/'));
222 foreach ($dirtpls as $reldir) {
224 if (file_exists($tmp)) {
225 $template_dir = preg_replace(
'/passwordforgotten\.tpl\.php$/',
'', $tmp);
229} elseif (file_exists(DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/tpl/passwordforgotten.tpl.php")) {
230 $template_dir = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/tpl/";
232 $template_dir = DOL_DOCUMENT_ROOT.
"/core/tpl/";
236 $focus_element =
'username';
238 $focus_element =
'password';
244$urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
245if (!empty(
$mysoc->logo_small) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.
$mysoc->logo_small)) {
246 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.
$mysoc->logo_small);
247} elseif (!empty(
$mysoc->logo_small) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.
$mysoc->logo)) {
248 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.
$mysoc->logo);
250} elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/img/dolibarr_logo.svg')) {
251 $urllogo = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/dolibarr_logo.svg';
252} elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
253 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
257$disabled =
'disabled';
258if (preg_match(
'/dolibarr/i', $mode)) {
272$parameters = array(
'entity' =>
GETPOSTINT(
'entity'));
273$hookmanager->executeHooks(
'getPasswordForgottenPageOptions', $parameters);
274if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
275 $morelogincontent = $hookmanager->resArray;
277 $morelogincontent = $hookmanager->resPrint;
281$parameters = array(
'entity' =>
GETPOSTINT(
'entity'));
282$reshook = $hookmanager->executeHooks(
'getPasswordForgottenPageExtraOptions', $parameters);
283$moreloginextracontent = $hookmanager->resPrint;
285if (empty($setnewpassword)) {
286 include $template_dir.
'passwordforgotten.tpl.php';
288 include $template_dir.
'passwordreset.tpl.php';
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage Dolibarr users.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...