Merge pull request 'feat: added authorization' (#5) from develop into production

Reviewed-on: #5
production
Евгений Сугоняко 2024-05-11 12:41:39 +00:00
commit 7b16271dcf
3 changed files with 10 additions and 2 deletions

View File

@ -18,10 +18,12 @@ func _init():
#--------------------------------------------------------------------------------------------------#
# RPC Client
@rpc("authority", "reliable", "call_remote", 1)
func authorizated(_token, _isAuthorized):
func authorizated(_name, _token, _isAuthorized):
if _isAuthorized:
if GATEWAY.debug:
print("Client token: " + _token)
token = _token
playerName = _name
GATEWAY.emit_signal("authorizated")
else:
GATEWAY.emit_signal("unauthorizated")

View File

@ -12,6 +12,7 @@ func _ready():
multiplayer.server_disconnected.connect(_on_server_disconnected)
multiplayer.connection_failed.connect(_on_connected_fail)
GATEWAY.unauthorizated.connect(_on_authorization_fail)
GATEWAY.authorizated.connect(_on_authorization_ok)
#--------------------------------------------------------------------------------------------------#
@ -29,7 +30,7 @@ func _on_login_btn_button_down():
if response != Error.OK:
InfoText.text = "Error connect to %s on port %s. ERROR: %s" % [GATEWAY.settings.Ip, GATEWAY.settings.Port, error_string(response)]
else:
response = GATEWAY.rpc_id(1, 'authorization', LoginInput.text, PasswordInput.text)
response = GATEWAY.rpc_id(1, 'authorization', LoginInput.text, PasswordInput.text.md5_text())
func _on_connected_ok():
@ -56,3 +57,7 @@ func _on_authorization_fail():
LoginBtn.disabled = false
LoginInput.editable = true
PasswordInput.editable = true
func _on_authorization_ok():
pass

View File

@ -13,6 +13,7 @@ var clientId : int
# Signals
signal unauthorizated
signal authorizated
#--------------------------------------------------------------------------------------------------#