Indefero

Indefero Commit Details


Date:2010-02-22 15:27:31 (14 years 9 months ago)
Author:Loic d'Anterroches
Branch: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:cc6f1c7cd86266c79a46cfd2e87fa293026dfb6a
Parents: 5d24931d9bb520718996461c6f6801e34bc00360
Message:Added ticket 165, multiple SSH keys per user.

Changes:

File differences

src/IDF/Form/UserAccount.php
9494
9595
9696
97
97
9898
9999
100100
......
105105
106106
107107
108
109108
110109
111110
......
151150
152151
153152
154
155
156
157
158
159
160
161
153
154
162155
163156
164157
158
159
160
165161
166162
167163
168
169
170
171
172
173164
174165
175166
......
198189
199190
200191
192
193
194
195
196
197
198
199
200
201
202
203
204
201205
202206
203207
$this->fields['ssh_key'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Your public SSH key'),
'label' => __('Add a public SSH key'),
'initial' => '',
'widget_attrs' => array('rows' => 3,
'cols' => 40),
}
/**
* Save the model in the database.
*
$this->user->setMessage(sprintf(__('A validation email has been sent to "%s" to validate the email address change.'), Pluf_esc($new_email)));
}
$this->user->setFromFormData($this->cleaned_data);
// Get keys
$keys = $this->user->get_idf_key_list();
if ($keys->count() > 0) {
$key = $keys[0];
if ('' !== $this->cleaned_data['ssh_key']) {
$key->content = $this->cleaned_data['ssh_key'];
}
} else {
// Add key as needed.
if ('' !== $this->cleaned_data['ssh_key']) {
$key = new IDF_Key();
$key->user = $this->user;
$key->content = $this->cleaned_data['ssh_key'];
if ($commit) {
$key->create();
}
}
if ($commit) {
$this->user->update();
if ($key->id != '') {
$key->update();
} else {
$key->create();
}
if ($update_pass) {
/**
* [signal]
return $this->user;
}
function clean_ssh_key()
{
$key = trim($this->cleaned_data['ssh_key']);
if (strlen($key) == 0) {
return '';
}
$key = str_replace(array("\n", "\r"), '', $key);
if (!preg_match('#^ssh\-[a-z]{3}\s(\S+)\s\S+$#', $key, $matches)) {
throw new Pluf_Form_Invalid(__('The format of the key is not valid. It must start with ssh-dss or ssh-rsa, a long string on a single line and at the end a comment.'));
}
return $key;
}
function clean_last_name()
{
$last_name = trim($this->cleaned_data['last_name']);
src/IDF/Key.php
7070
7171
7272
73
74
75
76
77
7378
7479
7580
......
97102
98103
99104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
100131
);
}
function showCompact()
{
return Pluf_Template::markSafe(Pluf_esc(substr($this->content, 0, 25)).' [...] '.Pluf_esc(substr($this->content, -55)));
}
function postSave($create=false)
{
/**
'IDF_Key', $params);
}
function preDelete()
{
/**
* [signal]
*
* IDF_Key::preDelete
*
* [sender]
*
* IDF_Key
*
* [description]
*
* This signal allows an application to perform special
* operations before a key is deleted.
*
* [parameters]
*
* array('key' => $key)
*
*/
$params = array('key' => $this);
Pluf_Signal::send('IDF_Key::preDelete',
'IDF_Key', $params);
}
}
src/IDF/Plugin/SyncGit.php
4747
4848
4949
50
50
5151
5252
return;
}
@touch(Pluf::f('idf_plugin_syncgit_sync_file'));
@chmod(Pluf::f('idf_plugin_syncgit_sync_file'), 0666);
@chmod(Pluf::f('idf_plugin_syncgit_sync_file'), 0777);
}
}
src/IDF/Views/User.php
124124
125125
126126
127
128
129
130
131
132127
133128
134129
135130
136
131
137132
138133
139134
140135
141136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
142157
143158
144159
$form = new IDF_Form_UserAccount($data, $params);
}
$keys = $request->user->get_idf_key_list();
if ($keys->count() > 0 and strlen($keys[0]->content) > 30) {
$ssh_key = Pluf_Template::markSafe('<span class="mono">'.Pluf_esc(substr($keys[0]->content, 0, 30)).'...</span><br /><span class="helptext">'.__('Truncated for security reasons.').'</span>');
} else {
$ssh_key = __('You have not upload your public SSH key yet.');
}
return Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
array('page_title' => __('Your Account'),
'api_key' => $api_key,
'ext_pass' => $ext_pass,
'ssh_key' => $ssh_key,
'keys' => $keys,
'form' => $form),
$request);
}
/**
* Delete a SSH key.
*
* This is redirecting to the preferences
*/
public $deleteKey_precond = array('Pluf_Precondition::loginRequired');
public function deleteKey($request, $match)
{
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::myAccount');
if ($request->method == 'POST') {
$key = Pluf_Shortcuts_GetObjectOr404('IDF_Key', $match[1]);
if ($key->user != $request->user->id) {
return new Pluf_HTTP_Response_Forbidden($request);
}
$key->delete();
$request->user->setMessage(__('The SSH key has been deleted.'));
}
return new Pluf_HTTP_Response_Redirect($url);
}
/**
* Enter the key to change an email address.
*
* This is redirecting to changeEmailDo
src/IDF/conf/urls.php
422422
423423
424424
425
426
427
428
429
430
425431
'model' => 'IDF_Views_User',
'method' => 'changeEmailDo');
$ctl[] = array('regex' => '#^/preferences/key/(\d+)/delete/$#',
'base' => $base,
'model' => 'IDF_Views_User',
'method' => 'deleteKey');
return $ctl;
src/IDF/relations.php
7474
7575
7676
77
78
7779
7880
array('IDF_Plugin_SyncGit', 'entry'));
Pluf_Signal::connect('IDF_Project::created',
array('IDF_Plugin_SyncGit', 'entry'));
Pluf_Signal::connect('IDF_Key::preDelete',
array('IDF_Plugin_SyncGit', 'entry'));
return $m;
src/IDF/templates/idf/user/myaccount.html
5656
5757
5858
59
6059
6160
6261
......
8079
8180
8281
82
83
84
85
86
87
88
89
90
91
8392
8493
8594
<tr>
<th>{$form.f.ssh_key.labelTag}:</th>
<td>{if $form.f.ssh_key.errors}{$form.f.ssh_key.fieldErrors}{/if}
{$ssh_key}<br />
{$form.f.ssh_key|unsafe}<br />
<span class="helptext">{$form.f.ssh_key.help_text}</span>
</td>
</tr>
</table>
</form>
{if count($keys)}
<table summary=" " class="recent-issues">
<tr><th colspan="2">{trans 'Your Current SSH Keys'}</th></tr>
{foreach $keys as $key}<tr><td>
<span class="mono">{$key.showCompact()}</span></td><td> <form class="star" method="post" action="{url 'IDF_Views_User::deleteKey', array($key.id)}"><input type="image" src="{media '/idf/img/trash.png'}" name="submit" value="{trans 'Delete this key'}" /></form>
</td>
</tr>{/foreach}
</table>
{/if}
{/block}
{block context}
<div class="issue-submit-info">

Archive Download the corresponding diff file

Page rendered in 0.10073s using 14 queries.