[Xfce4-commits] <moka:master> Add support for storing public keys.

Nick Schermer noreply at xfce.org
Sun Nov 20 14:30:03 CET 2011


Updating branch refs/heads/master
         to c1160e518f1a4fa144b62daed587be8203f61d6c (commit)
       from 67afb23169419dd830adcf330dc2a4badebe1081 (commit)

commit c1160e518f1a4fa144b62daed587be8203f61d6c
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Apr 3 14:09:28 2011 +0200

    Add support for storing public keys.

 lib/controllers/maintainers.rb |   10 +++++++++-
 lib/models/maintainer.rb       |    9 ++++++---
 lib/views/maintainer.erb       |    1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/controllers/maintainers.rb b/lib/controllers/maintainers.rb
index abedddd..15e5e91 100755
--- a/lib/controllers/maintainers.rb
+++ b/lib/controllers/maintainers.rb
@@ -31,11 +31,19 @@ module Moka
               end
             end
 
+            # cleanup the pubkeys
+            pubkeys = []
+            params[:pubkeys].split("\n").each do |key|
+              key = key.strip
+              pubkeys.push(key) if not key.empty?
+            end
+
             @maintainer.email = params[:email]
             @maintainer.realname = params[:realname]
+            @maintainer.pubkeys = pubkeys
             @maintainer.save
 
-            error_set(:succeed, 'The changes to your name and password have been saved.')
+            error_set(:succeed, 'The changes to your profile have been saved.')
           else
             if authentication_user.username == @maintainer.username
               error_set(:password, 'You did not enter your old password correctly.')
diff --git a/lib/models/maintainer.rb b/lib/models/maintainer.rb
index 6e6ff0c..9231d4e 100755
--- a/lib/models/maintainer.rb
+++ b/lib/models/maintainer.rb
@@ -9,13 +9,15 @@ module Moka
       attr_accessor :password
       attr_accessor :email
       attr_accessor :roles
+      attr_accessor :pubkeys
     
-      def initialize(username, realname, password, email, roles)
+      def initialize(username, realname, password, email, roles, pubkeys)
         @username = username
         @realname = realname
         @password = password
         @email = email
         @roles = if roles.nil? then [] else roles end
+        @pubkeys = if pubkeys.nil? then [] else pubkeys end
       end
     
       def to_json(*a)
@@ -25,12 +27,13 @@ module Moka
           'realname' => realname,
           'password' => password,
           'email' => email,
-          'roles' => roles
+          'roles' => roles,
+          'pubkeys' => pubkeys
         }.to_json(*a)
       end
     
       def self.json_create(o)
-        new(o['username'], o['realname'], o['password'], o['email'], o['roles'])
+        new(o['username'], o['realname'], o['password'], o['email'], o['roles'], o['pubkeys'])
       end
     
       def ==(other)
diff --git a/lib/views/maintainer.erb b/lib/views/maintainer.erb
index 3c61f58..911daf9 100755
--- a/lib/views/maintainer.erb
+++ b/lib/views/maintainer.erb
@@ -7,6 +7,7 @@
   <fieldset>
     <p><label for="email">Email address:</label> <input type="text" id="email" name="email" value="<%= @maintainer.email %>"/></p>
     <p><label for="realname">Real Name:</label> <input type="text" id="realname" name="realname" value="<%= @maintainer.realname %>"/></p>
+    <p><label for="pubkeys">SSH public-keys:</label> <textarea id="pubkeys" name="pubkeys" rows="5" wrap="off"><%= @maintainer.pubkeys.join("\n") %></textarea></p>
     <% if not Moka::Models::Maintainer.use_http_auth? %>
       <hr />
       <p>Leave the password fields empty if you don't want to set a new password. The password needs to be at least 6 characters long.</p>


More information about the Xfce4-commits mailing list