source: trunk/preferences/templates/default/changepassword_default.php @ 2463

Revision 2463, 4.0 KB checked in by niltonneto, 14 years ago (diff)

Ticket #1031 - Removido código que executa a alteração de senha pela segunda vez.

Line 
1<?php
2
3        /***************************************************************************
4        * Expresso Livre                                                           *
5        * http://www.expressolivre.org                                             *
6        * --------------------------------------------                             *
7        *  This program is free software; you can redistribute it and/or modify it *
8        *  under the terms of the GNU General Public License as published by the   *
9        *  Free Software Foundation; either version 2 of the License, or (at your  *
10        *  option) any later version.                                              *
11        \**************************************************************************/
12
13                // Default number of letters = 3
14                if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass'])
15                        $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3;
16                // Default number of special letters = 0
17                if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass'])
18                        $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0;
19                if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd))
20                {
21                        $errors[] = lang('Your actual password is wrong');
22                }
23                else if ($n_passwd != $n_passwd_2)
24                {
25                        $errors[] = lang('The two passwords are not the same');
26                }
27                else if ($a_passwd == $n_passwd)
28                {
29                        $errors[] = lang('Your old password and your new password are the same. Choose a different new password');
30                }
31                else if (! $n_passwd)
32                {
33                        $errors[] = lang('You must enter a password');
34                }
35                else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] )
36                {
37                        $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']);
38                }
39
40                // Special Letters
41                $speccial_letter = 0;
42                for ($i=0; $i<strlen($n_passwd); $i++)
43                {
44                        $letter = $n_passwd[$i];
45                        if (! ereg ("[a-zA-Z]", $letter ) )
46                                $speccial_letter++;
47                }
48                if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'])
49                {
50                        $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']);
51                }
52
53                if(is_array($errors))
54                {
55                        $GLOBALS['phpgw']->common->phpgw_header();
56                        echo parse_navbar();
57                        $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
58                        $GLOBALS['phpgw']->template->pfp('out','form');
59                        $GLOBALS['phpgw']->common->phpgw_exit(True);
60                }
61
62                $o_passwd = $GLOBALS['phpgw_info']['user']['passwd'];
63                $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd);
64                if(!$passwd_changed)
65                {
66                        $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.';
67                        $GLOBALS['phpgw']->common->phpgw_header();
68                        echo parse_navbar();
69                        $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
70                        $GLOBALS['phpgw']->template->pfp('out','form');
71                        $GLOBALS['phpgw']->common->phpgw_exit(True);
72                }
73                else
74                {
75                        $GLOBALS['phpgw_info']['user']['passwd'] = $passwd_changed;
76                        $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
77                        $GLOBALS['hook_values']['old_passwd'] = $o_passwd;
78                        $GLOBALS['hook_values']['new_passwd'] = $n_passwd;
79                        $GLOBALS['phpgw']->hooks->process('changepassword');
80
81                        if($GLOBALS['phpgw_info']['server']['certificado'])
82                        {
83                        if(!$GLOBALS['phpgw_info']['server']['atributousuarios'] or $GLOBALS['phpgw_info']['server']['atributousuarios'] == "person")
84                                {
85                                        $RR = grava_senha_criptografada_com_certificado_no_ldap($GLOBALS['phpgw_info']['user']['account_id'],$n_passwd);
86                                }
87                        }
88
89                        if ($GLOBALS['phpgw_info']['server']['use_https'] == 1)
90                                Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php');
91                        else
92                                $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18');
93                }
94
95?>
Note: See TracBrowser for help on using the repository browser.