mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
Merge pull request #152 from juanmont/F-4839
F #4839 Added a new login error when oned is not running
This commit is contained in:
commit
7c05a28fbb
@ -31,10 +31,8 @@ module OpenNebulaCloudAuth
|
||||
#
|
||||
def do_auth(env, params={})
|
||||
auth = Rack::Auth::Basic::Request.new(env)
|
||||
|
||||
if auth.provided? && auth.basic?
|
||||
username, password = auth.credentials
|
||||
|
||||
authenticated = false
|
||||
|
||||
invalid_chars =
|
||||
@ -72,11 +70,11 @@ module OpenNebulaCloudAuth
|
||||
|
||||
rc = user.info
|
||||
end
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if logger
|
||||
logger.error{ "User #{username} could not be authenticated"}
|
||||
logger.error { rc.message }
|
||||
throw Exception(rc.message) if rc.is_exml_rpc_call?()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
@ -201,7 +201,7 @@ module OpenNebula
|
||||
response[1] #response[1..-1]
|
||||
end
|
||||
rescue Exception => e
|
||||
Error.new(e.message)
|
||||
Error.new(e.message, Error::EXML_RPC_CALL)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,8 +28,10 @@ module OpenNebula
|
||||
EACTION = 0x0800
|
||||
EXML_RPC_API = 0x1000
|
||||
EINTERNAL = 0x2000
|
||||
ENOTDEFINED = 0x1111
|
||||
|
||||
EALLOCATE = 0x4000
|
||||
ENOTDEFINED = 0xF001
|
||||
EXML_RPC_CALL = 0xF002
|
||||
|
||||
attr_reader :message, :errno
|
||||
|
||||
# +message+ Description of the error
|
||||
@ -42,6 +44,11 @@ module OpenNebula
|
||||
def to_str()
|
||||
@message
|
||||
end
|
||||
|
||||
def is_exml_rpc_call?()
|
||||
@errno == EXML_RPC_CALL
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Returns true if the object returned by a method of the OpenNebula
|
||||
@ -49,4 +56,5 @@ module OpenNebula
|
||||
def self.is_error?(value)
|
||||
value.class==OpenNebula::Error
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user