From 75777daf4ba1654bccd954f22082435fc998daa4 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Sat, 27 Feb 2010 18:09:02 +0100 Subject: [PATCH] Fixed to prevent uploading several times the same key. --- src/IDF/Form/UserAccount.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/IDF/Form/UserAccount.php b/src/IDF/Form/UserAccount.php index fc3a8d0..e64297b 100644 --- a/src/IDF/Form/UserAccount.php +++ b/src/IDF/Form/UserAccount.php @@ -220,6 +220,17 @@ class IDF_Form_UserAccount extends Pluf_Form throw new Pluf_Form_Invalid(__('Please check the key as it does not appears to be a valid key.')); } } + // If $user, then check if not the same key stored + if ($user) { + $ruser = Pluf::factory('Pluf_User', $user); + if ($ruser->id > 0) { + $sql = new Pluf_SQL('content=%s', array($key)); + $keys = Pluf::factory('IDF_Key')->getList(array('filter' => $sql->gen())); + if (count($keys) > 0) { + throw new Pluf_Form_Invalid(__('You already have uploaded this SSH key.')); + } + } + } return $key; }