Skip to content

Commit bde5243

Browse files
author
Patrick Anders
committed
add lost_password_function
1 parent a66bbd6 commit bde5243

File tree

7 files changed

+64
-38
lines changed

7 files changed

+64
-38
lines changed

interface/web/admin/form/users.tform.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@
260260
'maxlength' => '2',
261261
'rows' => '',
262262
'cols' => ''
263+
),
264+
'lost_password_function' => array (
265+
'datatype' => 'INTEGER',
266+
'formtype' => 'CHECKBOX',
267+
'regex' => '',
268+
'errmsg' => '',
269+
'default' => 1,
270+
'value' => array(0 => 0, 1 => 1),
271+
'separator' => '',
272+
'width' => '30',
273+
'maxlength' => '255',
274+
'rows' => '',
275+
'cols' => ''
263276
)
264277
//#################################
265278
// ENDE Datenbankfelder

interface/web/admin/lib/lang/de_users.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.';
3131
$wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
3232
$wb['username_error_collision'] = 'Der Benutzername darf nicht <b>web<b> oder <b>web<b> gefolgt von einer Zahl sein.';
3333
$wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin';
34+
$wb['lost_password_function_txt'] = 'Passwort vergessen Funktion steht zur Verfügung';
3435
?>

interface/web/admin/lib/lang/en_users.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ $wb['password_mismatch_txt'] = 'The passwords do not match.';
3131
$wb['password_match_txt'] = 'The passwords do match.';
3232
$wb['username_error_collision'] = 'The username may not be web or web plus a number."';
3333
$wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin';
34+
$wb['lost_password_function_txt'] = 'Forgot password function is available';
3435
?>

interface/web/admin/templates/users_user_edit.htm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
6060
{tmpl_var name='language'}
6161
</select>
6262
</div>
63+
<div class="ctrlHolder">
64+
<p class="label">{tmpl_var name='lost_password_function_txt'}</p>
65+
<div class="multiField">
66+
{tmpl_var name='lost_password_function'}
67+
</div>
68+
</div>
6369
</fieldset>
6470

6571
<input type="hidden" name="id" value="{tmpl_var name='id'}">
@@ -70,4 +76,4 @@ <h2><tmpl_var name="list_head_txt"></h2>
7076
</div>
7177
</div>
7278

73-
</div>
79+
</div>

interface/web/login/lib/lang/de.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ $wb['theme_not_compatible'] = 'Das gewählte Design ist mit dieser ISPConfig Ver
2424
$wb['back_txt'] = 'Zur&uuml;ck';
2525
$wb['stay_logged_in_txt'] = 'Dauerhaft eingeloggt bleiben';
2626
$wb['email_error'] = 'Email contains unallowed characters or has a invalid format.';
27+
$wb['lost_password_function_disabled_txt'] = 'Die Passwort vergessen Funktion steht für diesen Benutzer nicht zur Verfügung.';
2728
?>

interface/web/login/lib/lang/en.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ $wb['back_txt'] = 'Back';
2424
$wb['error_maintenance_mode'] = 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.';
2525
$wb['theme_not_compatible'] = 'The chosen theme is not compatible with the current ISPConfig version. Please check for a new version of the theme.<br />The default theme as been activated automatically.';
2626
$wb['stay_logged_in_txt'] = 'Keep me logged in';
27-
?>
27+
$wb['lost_password_function_disabled_txt'] = 'The lost password function is not available for this user.';
28+
?>

interface/web/login/password_reset.php

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
Redistribution and use in source and binary forms, with or without modification,
88
are permitted provided that the following conditions are met:
99
10-
* Redistributions of source code must retain the above copyright notice,
11-
this list of conditions and the following disclaimer.
12-
* Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
* Neither the name of ISPConfig nor the names of its contributors
16-
may be used to endorse or promote products derived from this software without
17-
specific prior written permission.
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
1818
1919
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2020
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -26,7 +26,7 @@
2626
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2727
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
*/
29+
*/
3030

3131
require_once '../../lib/config.inc.php';
3232
require_once '../../lib/app.inc.php';
@@ -54,36 +54,39 @@
5454
$username = $app->db->quote($_POST['username']);
5555
$email = $app->db->quote($_POST['email']);
5656

57-
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' AND email = '$email'");
57+
$client = $app->db->queryOneRecord("SELECT client.*, sys_user.lost_password_function FROM client,sys_user WHERE client.username = '$username' AND client.email = '$email' AND client.client_id = sys_user.client_id");
5858

59-
if($client['client_id'] > 0) {
60-
$new_password = $app->auth->get_random_password();
61-
$new_password_encrypted = $app->auth->crypt_password($new_password);
62-
$new_password_encrypted = $app->db->quote($new_password_encrypted);
63-
64-
$username = $app->db->quote($client['username']);
65-
$app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'");
66-
$app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'");
67-
$app->tpl->setVar("message", $wb['pw_reset']);
68-
69-
$app->uses('getconf,ispcmail');
70-
$mail_config = $app->getconf->get_global_config('mail');
71-
if($mail_config['smtp_enabled'] == 'y') {
72-
$mail_config['use_smtp'] = true;
73-
$app->ispcmail->setOptions($mail_config);
74-
}
75-
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
76-
$app->ispcmail->setSubject($wb['pw_reset_mail_title']);
77-
$app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password);
78-
$app->ispcmail->send(array($client['contact_name'] => $client['email']));
79-
$app->ispcmail->finish();
80-
81-
$app->plugin->raiseEvent('password_reset', true);
82-
$app->tpl->setVar("msg", $wb['pw_reset']);
59+
if($client['lost_password_function'] == 0) {
60+
$app->tpl->setVar("error", $wb['lost_password_function_disabled_txt']);
8361
} else {
84-
$app->tpl->setVar("error", $wb['pw_error']);
62+
if($client['client_id'] > 0) {
63+
$new_password = $app->auth->get_random_password();
64+
$new_password_encrypted = $app->auth->crypt_password($new_password);
65+
$new_password_encrypted = $app->db->quote($new_password_encrypted);
66+
67+
$username = $app->db->quote($client['username']);
68+
$app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'");
69+
$app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'");
70+
$app->tpl->setVar("message", $wb['pw_reset']);
71+
72+
$app->uses('getconf,ispcmail');
73+
$mail_config = $app->getconf->get_global_config('mail');
74+
if($mail_config['smtp_enabled'] == 'y') {
75+
$mail_config['use_smtp'] = true;
76+
$app->ispcmail->setOptions($mail_config);
77+
}
78+
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
79+
$app->ispcmail->setSubject($wb['pw_reset_mail_title']);
80+
$app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password);
81+
$app->ispcmail->send(array($client['contact_name'] => $client['email']));
82+
$app->ispcmail->finish();
83+
84+
$app->plugin->raiseEvent('password_reset', true);
85+
$app->tpl->setVar("msg", $wb['pw_reset']);
86+
} else {
87+
$app->tpl->setVar("error", $wb['pw_error']);
88+
}
8589
}
86-
8790
} else {
8891
$app->tpl->setVar("msg", $wb['pw_error_noinput']);
8992
}

0 commit comments

Comments
 (0)