Feature #4714: Fix bug in handling oneuser token --set with no tokens

This commit is contained in:
Jaime Melis committed 2016-09-02 16:19:58 +02:00
1 parent 9c929148fc
commit ee626f6fcb
2 files changed
+7 -2

No files matched your search

+6 -2
View File
@@ -387,7 +387,11 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
def find_token(user, token, show_expired=false)
user_hash = user.to_hash
valid_tokens = [user_hash["USER"]["LOGIN_TOKEN"]].flatten.map do |e|
valid_tokens = [user_hash["USER"]["LOGIN_TOKEN"]].flatten.compact
return [] if valid_tokens.empty?
valid_tokens.map do |e|
next unless e["TOKEN"].start_with?(token)
if !show_expired
@@ -395,7 +399,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
end
e["TOKEN"]
end.compact
end.compact if !valid_tokens.empty?
end
private
+1
View File
@@ -593,6 +593,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
if options[:set]
token = helper.find_token(user, options[:set])
if token.count > 1
exit_with_code 1, "More than one token starting with '#{options[:set]}' found."
elsif token.count == 0