Skip to content

Commit

Permalink
Should fix issues documented in issue catops#9
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Watson committed Nov 14, 2016
1 parent 3e2eacc commit 887a46d
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/hubot-keys.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ module.exports = (robot) ->
class Keys

keyForUserName: (name) ->
console.log name
user = robot.brain.userForName name
console.log "_________________"
console.log user
user.key

keyForUserId: (id) ->
Expand All @@ -35,7 +32,6 @@ module.exports = (robot) ->

addKeyForUserId: (id, key) ->
user = robot.brain.userForId id
console.log user
user.key = key
user.key

Expand All @@ -55,18 +51,14 @@ module.exports = (robot) ->
key = res.match[2]
if !/ssh-rsa AAAA[0-9A-Za-z+\/]+[=]{0,3}( [^@]+@[^@]+)?/.test(key)
return res.send "`#{key}` is not a valid public SSH key. You can find your key with `cat ~/.ssh/id_rsa.pub`."
console.log res.envelope.user
robot.keys.addKeyForUserId res.envelope.user.id, key
res.send "Okay, I stored your public SSH key as #{key.substring(0, 40)}..."

robot.respond /(what is |show )?([^\s]+)('s?)? public (ssh )?key$/i, (res) ->
user = res.match[2]
console.log res
if user == 'my'
# Return the username
console.log "in_here"
user = res.envelope.user.name
console.log robot.keys
key = robot.keys.keyForUserName user
if !key
return res.send "I don't know #{user}'s public SSH key. Add it with `#{robot.name} my public key is <key>`. You can find your key with `cat ~/.ssh/id_rsa.pub`."
Expand Down

0 comments on commit 887a46d

Please sign in to comment.