lib/aerospike/connection/authenticate.rb in aerospike-2.22.0 vs lib/aerospike/connection/authenticate.rb in aerospike-2.23.0
- old
+ new
@@ -36,13 +36,11 @@
INVALID_SESSION_ERR = [ResultCode::INVALID_CREDENTIAL,
ResultCode::EXPIRED_SESSION]
def call(conn, cluster)
command = LoginCommand.new
- if !cluster.session_valid?
- command.authenticate_new(conn, cluster)
- else
+ if cluster.session_valid?
begin
command.authenticate_via_token(conn, cluster)
rescue => ae
# always reset session info on errors to be on the safe side
cluster.reset_session_info
@@ -52,9 +50,11 @@
return true
end
end
raise ae
end
+ else
+ command.authenticate_new(conn, cluster)
end
true
rescue ::Aerospike::Exceptions::Aerospike
conn.close if conn