@@ -98,12 +98,18 @@ def self.user_to_user_token(user)
98
98
99
99
# Strip leading and trailing whitespace
100
100
def strip_whitespace
101
+ # Don't mess with existing keys (since cannot change key text anyway)
102
+ return if !new_record?
103
+
101
104
self . title = title . strip
102
105
self . key = key . strip
103
106
end
104
107
105
108
# Remove control characters from key
106
109
def remove_control_characters
110
+ # Don't mess with existing keys (since cannot change key text anyway)
111
+ return if !new_record?
112
+
107
113
# First -- let the first control char or space stand (to divide key type from key)
108
114
# Really, this is catching a special case in which there is a \n between type and key.
109
115
# Most common case turns first space back into space....
@@ -126,7 +132,7 @@ def has_not_been_changed
126
132
end
127
133
128
134
def key_format_and_uniqueness
129
- return if key . blank? || ! new_record?
135
+ return if key . blank?
130
136
131
137
# First, check that key crypto type is present and of correct form. Also, decode base64 and see if key
132
138
# crypto type matches. Note that we ignore presence of comment!
@@ -185,6 +191,7 @@ def key_format_and_uniqueness
185
191
allkeys += ( GitolitePublicKey . active . all )
186
192
187
193
allkeys . each do |existingkey |
194
+ next if existingkey . id == id
188
195
existingpieces = existingkey . key . match ( /^(\S +)\s +(\S +)/ )
189
196
if existingpieces && ( existingpieces [ 2 ] == keypieces [ 2 ] )
190
197
# Hm.... have a duplicate key!
0 commit comments