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 Client
@rpc("authority", "reliable", "call_remote", 1) @rpc("authority", "reliable", "call_remote", 1)
func authorizated(_token, _isAuthorized): func authorizated(_name, _token, _isAuthorized):
if _isAuthorized: if _isAuthorized:
if GATEWAY.debug: if GATEWAY.debug:
print("Client token: " + _token) print("Client token: " + _token)
token = _token token = _token
playerName = _name
GATEWAY.emit_signal("authorizated")
else: else:
GATEWAY.emit_signal("unauthorizated") GATEWAY.emit_signal("unauthorizated")

View File

@ -12,6 +12,7 @@ func _ready():
multiplayer.server_disconnected.connect(_on_server_disconnected) multiplayer.server_disconnected.connect(_on_server_disconnected)
multiplayer.connection_failed.connect(_on_connected_fail) multiplayer.connection_failed.connect(_on_connected_fail)
GATEWAY.unauthorizated.connect(_on_authorization_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: if response != Error.OK:
InfoText.text = "Error connect to %s on port %s. ERROR: %s" % [GATEWAY.settings.Ip, GATEWAY.settings.Port, error_string(response)] InfoText.text = "Error connect to %s on port %s. ERROR: %s" % [GATEWAY.settings.Ip, GATEWAY.settings.Port, error_string(response)]
else: 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(): func _on_connected_ok():
@ -56,3 +57,7 @@ func _on_authorization_fail():
LoginBtn.disabled = false LoginBtn.disabled = false
LoginInput.editable = true LoginInput.editable = true
PasswordInput.editable = true PasswordInput.editable = true
func _on_authorization_ok():
pass

View File

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