summaryrefslogtreecommitdiff
path: root/lib/tfa/cli.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tfa/cli.rb')
-rw-r--r--lib/tfa/cli.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/tfa/cli.rb b/lib/tfa/cli.rb
index a73de1e..107f202 100644
--- a/lib/tfa/cli.rb
+++ b/lib/tfa/cli.rb
@@ -7,6 +7,7 @@ module TFA
desc "add NAME SECRET", "add a new secret to the database"
def add(name, secret)
+ secret = clean(secret)
storage.save(name, secret)
"Added #{name}"
end
@@ -18,7 +19,7 @@ module TFA
desc "totp NAME", "generate a Time based One Time Password"
def totp(name = nil)
- TotpCommand.new(storage).run([name])
+ TotpCommand.new(storage).run(name)
end
private
@@ -26,5 +27,13 @@ module TFA
def storage
@storage ||= Storage.new(filename: options[:filename] || 'tfa')
end
+
+ def clean(secret)
+ if secret.include?("=")
+ /secret=([^&]*)/.match(secret).captures.first
+ else
+ secret
+ end
+ end
end
end