Indefero

Indefero Commit Details


Date:2008-12-01 06:35:17 (16 years 1 month ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:d1911339d7f025e55a40dc90124090864175fb04
Parents: 9c5156e6ef34fa536363d8fa6f72e6d224954117
Message:Added signals when the user updates his password.

Changes:

File differences

src/IDF/Form/RegisterConfirmation.php
141141
142142
143143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
144166
145167
146168
        $this->_user->staff = false;
        if ($commit) {
            $this->_user->update();
            /**
             * [signal]
             *
             * Pluf_User::passwordUpdated
             *
             * [sender]
             *
             * IDF_Form_RegisterConfirmation
             *
             * [description]
             *
             * This signal is sent when the user updated his
             * password from his account page.
             *
             * [parameters]
             *
             * array('user' => $user)
             *
             */
            $params = array('user' => $this->_user);
            Pluf_Signal::send('Pluf_User::passwordUpdated',
                              'IDF_Form_RegisterConfirmation', $params);
        }
        return $this->_user;
    }
src/IDF/Form/UserAccount.php
8888
8989
9090
91
9192
9293
94
95
9396
9497
9598
9699
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
97124
98125
99126
            throw new Exception(__('Cannot save the model from an invalid form.'));
        }
        unset($this->cleaned_data['password2']);
        $update_pass = false;
        if (strlen($this->cleaned_data['password']) == 0) {
            unset($this->cleaned_data['password']);
        } else {
            $update_pass = true;
        }
        $this->user->setFromFormData($this->cleaned_data);
        if ($commit) {
            $this->user->update();
            if ($update_pass) {
                /**
                 * [signal]
                 *
                 * Pluf_User::passwordUpdated
                 *
                 * [sender]
                 *
                 * IDF_Form_UserAccount
                 *
                 * [description]
                 *
                 * This signal is sent when the user updated his
                 * password from his account page.
                 *
                 * [parameters]
                 *
                 * array('user' => $user)
                 *
                 */
                $params = array('user' => $this->user);
                Pluf_Signal::send('Pluf_User::passwordUpdated',
                                  'IDF_Form_UserAccount', $params);
            }
        }
        return $this->user;
    }
src/IDF/Views/User.php
4141
4242
4343
44
4445
4546
4647
......
5657
5758
5859
60
5961
6062
6163
        // As the password is salted, we can directly take the sha1 of
        // the salted password.
        $api_key = sha1($request->user->password);
        $ext_pass = substr(sha1($request->user->password.Pluf::f('secret_key')), 0, 8);
        $params = array('user' => $request->user);
        if ($request->method == 'POST') {
            $form = new IDF_Form_UserAccount($request->POST, $params);
        return Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
                                               array('page_title' => __('Your Account'),
                                                     'api_key' => $api_key,
                                                     'ext_pass' => $ext_pass,
                                                     'form' => $form),
                                               $request);
    }
src/IDF/templates/idf/user/myaccount.html
4040
4141
4242
43
43
44
45
46
47
48
49
4450
4551
46
52
4753
4854
4955
......
5763
5864
5965
60
66
6167
6268
6369
64
70
71
72
73
74
75
76
77
78
79
80
6581
6682
6783
{$form.f.password2|unsafe}
</td>
</tr>
<tr>
<tr class="pass-info" id="extra-password">
<th>{trans 'Extra password'}:</th>
<td><span class="mono">{$ext_pass}</span><br />
<span class="helptext">{trans 'This password is used to access some of the external systems managed by our infrastructure. It will be regenerated if you change your password.'}</span>
</td>
</tr>
<tr class="pass-info">
<th>{trans 'API key'}:</th>
<td><span class="mono">{$api_key}</span><br />
<span class="helptext">{trans 'Your API key will automatically be regenerated if you change your password.'}</span>
<span class="helptext">{trans 'Your API key will be regenerated automatically if you change your password.'}</span>
</td>
</tr>
<tr>
{block context}
<div class="issue-submit-info">
<p>{trans 'If possible, use your real name. By using your real name, people will have more trust in your comments and remarks.'}</p>
<p>{trans 'The API key is used to interact with this website using a program.'}</p>
<p>{trans 'The extra password is used to access some of the external systems and the API key is used to interact with this website using a program.'}</p>
</div>{/block}
{block javascript}<script type="text/javascript">
document.getElementById('id_first_name').focus()
document.getElementById('id_first_name').focus();
{literal}
$(document).ready(function() {
    // Hide the key password by default.
    $("#extra-password").before("{/literal}<tr id=\"form-block-0\"><td>&nbsp;</td><td><img style=\"vertical-align: text-bottom;\" src=\"{media '/idf/img/start.png'}\" alt=\" \" align=\"bottom\" /> <a id=\"form-show-0\" href=\"#\">{trans 'Show API key and extra password'}{literal}</a>.</td></tr>");
    $("#form-show-0").click(function(){
        $(".pass-info").show();
        $("#form-block-0").hide();
    });
    $(".pass-info").hide();
});{/literal}
</script>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.12090s using 13 queries.