mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 11:52:37 +09:00
Feature #4714: Fix bug in handling oneuser token --set with no tokens
This commit is contained in:
1 parent
9c929148fc
commit
ee626f6fcb
2 files changed
+7
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user