3 * Change user's password
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) Franck Villaume - Capgemini
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once('../env.inc.php');
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfcommon.'include/account.php';
28 session_require_login () ;
30 $u =& user_get_object(user_getid());
31 if (!$u || !is_object($u)) {
32 exit_error(_('Could Not Get User'),'my');
33 } elseif ($u->isError()) {
34 exit_error($u->getErrorMessage(),'my');
37 if (getStringFromRequest('submit')) {
38 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
39 exit_form_double_submit('my');
42 $old_passwd = getStringFromRequest('old_passwd');
43 $passwd = getStringFromRequest('passwd');
44 $passwd2 = getStringFromRequest('passwd2');
46 if ($u->getMD5Passwd() != md5($old_passwd)) {
47 form_release_key(getStringFromRequest('form_key'));
48 exit_error(_('Old password is incorrect'),'my');
51 if (strlen($passwd)<6) {
52 form_release_key(getStringFromRequest('form_key'));
53 exit_error(_('You must supply valid password (at least 6 chars)'),'my');
56 if ($passwd != $passwd2) {
57 form_release_key(getStringFromRequest('form_key'));
58 exit_error(_('New passwords do not match.'),'my');
61 if (!$u->setPasswd($passwd)) {
62 form_release_key(getStringFromRequest('form_key'));
63 exit_error(_('Could not change password: ').$u->getErrorMessage(),'my');
65 //plugin webcal change user password
67 plugin_hook('change_cal_password',user_getid());
70 site_user_header(array('title'=>_('Successfully Changed Password')));
75 printf(_('%1$s Password Change Confirmation'), forge_get_config ('forge_name'));
78 print '<div class="feedback">';
79 print _('Congratulations. You have changed your password.');
84 <?php printf(_('You should now <a href="%1$s">Return to User Prefs</a>.'),
85 util_make_url('/account/')) ?>
91 site_user_header(array('title'=>_('Change Password')));
94 <form action="<?php echo util_make_url('/account/change_pw.php'); ?>" method="post">
95 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
96 <p><?php echo _('Old Password') ?>:
97 <br /><input type="password" name="old_passwd" /></p>
98 <p><?php echo _('New Password (at least 6 chars)') ?>:
99 <br /><input type="password" name="passwd" /></p>
100 <p><?php echo _('New Password (repeat)') ?>:
101 <br /><input type="password" name="passwd2" /></p>
102 <p><input type="submit" name="submit" value="<?php echo _('Update password') ?>" /></p>
107 site_user_footer(array());