diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index b7e6fd15dcb..eaf2d602571 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -372,9 +372,19 @@ if (isset($conf->file->main_authentication) && preg_match('/google/', $conf->fil // Show error message if defined if (!empty($_SESSION['dol_loginmesg'])) { ?> -
- -
+
+ /', $message)) { // if it contains this comment, this is a warning message + $message = str_replace('', '', $message); + print '
'; + } else { + print '
'; + } + print dol_escape_htmltag($message); + print '
'; + ?> +
. */ - if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', 1); } @@ -234,15 +233,19 @@ if (!empty($morelogincontent)) {
- - - trans('SendNewPasswordDesc'); ?> - - -
- trans('AuthenticationDoesNotAllowSendNewPassword', $mode); ?> -
- +'; + print $langs->trans('SendNewPasswordDesc'); + print ''; + } +} else { + print '
'; + print $langs->trans('AuthenticationDoesNotAllowSendNewPassword', $mode); + print '
'; +} +?>
diff --git a/htdocs/core/tpl/passwordreset.tpl.php b/htdocs/core/tpl/passwordreset.tpl.php new file mode 100644 index 00000000000..1f35b1a251a --- /dev/null +++ b/htdocs/core/tpl/passwordreset.tpl.php @@ -0,0 +1,367 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// To show this page, we need parameters: setnewpassword=1&username=...&passworduidhash=... + +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', 1); +} + +// Protection to avoid direct call of template +if (empty($conf) || !is_object($conf)) { + print "Error, template page can't be called as URL"; + exit; +} + +// DDOS protection +$size = (int) $_SERVER['CONTENT_LENGTH']; +if ($size > 10000) { + $langs->loadLangs(array("errors", "install")); + httponly_accessforbidden('
'.$langs->trans("ErrorRequestTooLarge").'
'.$langs->trans("ClickHereToGoToApp").'
', 413, 1); +} + +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +header('Cache-Control: Public, must-revalidate'); +header("Content-type: text/html; charset=".$conf->file->character_set_client); + +if (GETPOST('dol_hide_topmenu')) { + $conf->dol_hide_topmenu = 1; +} +if (GETPOST('dol_hide_leftmenu')) { + $conf->dol_hide_leftmenu = 1; +} +if (GETPOST('dol_optimize_smallscreen')) { + $conf->dol_optimize_smallscreen = 1; +} +if (GETPOST('dol_no_mouse_hover')) { + $conf->dol_no_mouse_hover = 1; +} +if (GETPOST('dol_use_jmobile')) { + $conf->dol_use_jmobile = 1; +} + +// If we force to use jmobile, then we reenable javascript +if (!empty($conf->dol_use_jmobile)) { + $conf->use_javascript_ajax = 1; +} + +$php_self = $_SERVER['PHP_SELF']; +$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; +$php_self = str_replace('action=validatenewpassword', '', $php_self); + +$titleofpage = $langs->trans('ResetPassword'); + +// Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second +$arrayofjs = array(); + +$disablenofollow = 1; +if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) { + $disablenofollow = 0; +} +if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $disablenofollow = 0; +} + +print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); + + +$colorbackhmenu1 = '60,70,100'; // topmenu +if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) { + $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; +} +$colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $conf->global->THEME_ELDY_TOPMENU_BACK1) : (empty($user->conf->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $user->conf->THEME_ELDY_TOPMENU_BACK1); +$colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' + + +$edituser = new User($db); + + +// Validate parameters +if ($setnewpassword && $username && $passworduidhash) { + $result = $edituser->fetch('', $username); + if ($result < 0) { + $message = '
'.dol_escape_htmltag($langs->trans("ErrorTechnicalError")).'
'; + } else { + global $dolibarr_main_instance_unique_id; + + //print $edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id.' '.$passworduidhash; + if ($edituser->pass_temp && dol_verifyHash($edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id, $passworduidhash)) { + // Clear session + unset($_SESSION['dol_login']); + + // Parameters to reset the user are validated + } else { + $langs->load("errors"); + $message = '
'.$langs->trans("ErrorFailedToValidatePasswordReset").'
'; + } + } +} else { + $langs->load("errors"); + $message = '
'.$langs->trans("ErrorFailedToValidatePasswordReset").'
'; +} + + +?> + + +global->MAIN_LOGIN_BACKGROUND) ? '' : ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode('logos/'.$conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> + +dol_use_jmobile)) { ?> + + + + + + + + + + diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 46cb61ff3f0..d5701ba2224 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -181,6 +181,7 @@ SizeUnitfoot=foot SizeUnitpoint=point BugTracker=Bug tracker SendNewPasswordDesc=This form allows you to request a new password. It will be sent to your email address.
Change will become effective once you click on the confirmation link in the email.
Check your inbox. +EnterNewPasswordHere=Enter your new password here BackToLoginPage=Back to login page AuthenticationDoesNotAllowSendNewPassword=Authentication mode is %s.
In this mode, Dolibarr can't know nor change your password.
Contact your system administrator if you want to change your password. EnableGDLibraryDesc=Install or enable GD library on your PHP installation to use this option. diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 658c45a3753..96054b0d802 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -51,6 +51,8 @@ if (!$mode) { $username = GETPOST('username', 'alphanohtml'); $passworduidhash = GETPOST('passworduidhash', 'alpha'); +$setnewpassword = GETPOST('setnewpassword', 'aZ09'); + $conf->entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : 1); // Instantiate hooks of thirdparty module only if not already define @@ -90,7 +92,7 @@ if (empty($reshook)) { $edituser = new User($db); $result = $edituser->fetch('', $username); if ($result < 0) { - $message = '
'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'
'; + $message = '
'.dol_escape_htmltag($langs->trans("ErrorTechnicalError")).'
'; } else { global $dolibarr_main_instance_unique_id; @@ -98,7 +100,7 @@ if (empty($reshook)) { if ($edituser->pass_temp && dol_verifyHash($edituser->pass_temp.'-'.$edituser->id.'-'.$dolibarr_main_instance_unique_id, $passworduidhash)) { // Clear session unset($_SESSION['dol_login']); - $_SESSION['dol_loginmesg'] = $langs->transnoentitiesnoconv('NewPasswordValidated'); // Save message for the session page + $_SESSION['dol_loginmesg'] = ''.$langs->transnoentitiesnoconv('NewPasswordValidated'); // Save message for the session page $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0); dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database"); @@ -111,7 +113,8 @@ if (empty($reshook)) { } } } - // Action modif mot de passe + + // Action to set a temporary password and send email for reset if ($action == 'buildnewpassword' && $username) { $sessionkey = 'dol_antispam_value'; $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code')))); @@ -235,4 +238,8 @@ $parameters = array('entity' => GETPOST('entity', 'int')); $reshook = $hookmanager->executeHooks('getPasswordForgottenPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; -include $template_dir.'passwordforgotten.tpl.php'; // To use native PHP +if (empty($setnewpassword)) { + include $template_dir.'passwordforgotten.tpl.php'; // To use native PHP +} else { + include $template_dir.'passwordreset.tpl.php'; // To use native PHP +}