|
|
|
@ -143,3 +143,30 @@ func authorization(_login, _password):
|
|
|
|
|
FileManager.add_to_log("OK | Status: 200 | Message: CLIENT AUTHORIZATED id: %s" % [client_id])
|
|
|
|
|
else:
|
|
|
|
|
FileManager.add_to_log("WARNING | Status: %s | Message: CLIENT NOT AUTHORIZATED id: %s - Error: %s" % [STATUS.WARNING, client_id, "Invalid login or password"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc("any_peer", "reliable", "call_local", 1)
|
|
|
|
|
func registration(_login, _password):
|
|
|
|
|
var db = ORM.new()
|
|
|
|
|
var client_id : int = multiplayer.get_remote_sender_id()
|
|
|
|
|
var user = db.findOne("User", _login)
|
|
|
|
|
if user:
|
|
|
|
|
var reason = "User already exist"
|
|
|
|
|
var rpc_response = rpc_id(client_id, 'is_registrated', false, reason)
|
|
|
|
|
if rpc_response != Error.OK:
|
|
|
|
|
FileManager.add_to_log("ERROR | Status: %s | Message: CLIENT NOT REGISTRATED id: %s - Error: %s" % [STATUS.ERROR, client_id, error_string(rpc_response)])
|
|
|
|
|
else:
|
|
|
|
|
FileManager.add_to_log("WARNING | Status: %s | Message: CLIENT NOT REGISTRATED id: %s - Error: %s" % [STATUS.WARNING, client_id, reason])
|
|
|
|
|
else:
|
|
|
|
|
# Add user to DB
|
|
|
|
|
var rpc_response = rpc_id(client_id, 'is_registrated', true, "")
|
|
|
|
|
if rpc_response != Error.OK:
|
|
|
|
|
FileManager.add_to_log("ERROR | Status: %s | Message: CLIENT NOT REGISTRATED id: %s - Error: %s" % [STATUS.ERROR, client_id, error_string(rpc_response)])
|
|
|
|
|
else:
|
|
|
|
|
FileManager.add_to_log("OK | Status: 200 | Message: CLIENT REGISTRATED id: %s" % [client_id])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------#
|
|
|
|
|
# RPC Client
|
|
|
|
|
@rpc("any_peer", "reliable", "call_local", 1)
|
|
|
|
|
func is_registrated(): pass
|
|
|
|
|