From 17cfaeb71b0c674d3cc8d8ede3e3de18f1ac216a Mon Sep 17 00:00:00 2001 From: Mateo Miccino Date: Mon, 19 Aug 2024 13:20:11 -0300 Subject: [PATCH] fix: check if auth chain is expired on restoring the session (#444) fix: change open browser text when magic is not presented --- godot/src/ui/components/auth/lobby.gd | 6 +++++- godot/src/ui/components/auth/lobby.tscn | 1 + godot/src/ui/components/auth/magic_login.gd | 6 +++++- godot/src/ui/explorer.gd | 5 ----- lib/src/auth/dcl_player_identity.rs | 4 ++++ lib/src/auth/ephemeral_auth_chain.rs | 4 ++++ 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/godot/src/ui/components/auth/lobby.gd b/godot/src/ui/components/auth/lobby.gd index 3a3af28ca..72596372d 100644 --- a/godot/src/ui/components/auth/lobby.gd +++ b/godot/src/ui/components/auth/lobby.gd @@ -35,6 +35,8 @@ var _skip_lobby: bool = false @onready var backpack = %Backpack +@onready var button_open_browser = %Button_OpenBrowser + # TODO: Change screen orientation for Mobile #func set_portrait(): ##DisplayServer.screen_set_orientation(DisplayServer.SCREEN_PORTRAIT) @@ -68,8 +70,10 @@ func async_close_sign_in(generate_snapshots: bool = true): # gdlint:ignore = async-function-name func _ready(): var magic_login = %MagicLogin - if is_instance_valid(magic_login): + if is_instance_valid(magic_login) and magic_login.is_platform_supported(): magic_login.set_lobby(self) + else: + button_open_browser.text = "OPEN BROWSER" show_panel(control_loading) diff --git a/godot/src/ui/components/auth/lobby.tscn b/godot/src/ui/components/auth/lobby.tscn index 04481e449..cf53c180d 100644 --- a/godot/src/ui/components/auth/lobby.tscn +++ b/godot/src/ui/components/auth/lobby.tscn @@ -434,6 +434,7 @@ unique_name_in_owner = true layout_mode = 2 [node name="Button_OpenBrowser" type="Button" parent="Main/SignIn/VBoxContainer/VBoxContainer_SignInStep1"] +unique_name_in_owner = true custom_minimum_size = Vector2(320, 56) layout_mode = 2 focus_mode = 0 diff --git a/godot/src/ui/components/auth/magic_login.gd b/godot/src/ui/components/auth/magic_login.gd index 7eb7a4481..804466952 100644 --- a/godot/src/ui/components/auth/magic_login.gd +++ b/godot/src/ui/components/auth/magic_login.gd @@ -3,8 +3,12 @@ extends Control var lobby: Lobby = null +func is_platform_supported(): + return OS.get_name() == "Android" + + func _ready(): - if OS.get_name() != "Android": + if !is_platform_supported(): queue_free() return diff --git a/godot/src/ui/explorer.gd b/godot/src/ui/explorer.gd index 7154204b2..8fb233cf3 100644 --- a/godot/src/ui/explorer.gd +++ b/godot/src/ui/explorer.gd @@ -100,8 +100,6 @@ func _ready(): virtual_joystick.mouse_filter = Control.MOUSE_FILTER_IGNORE virtual_joystick_orig_position = virtual_joystick.get_position() - label_ram.visible = OS.has_feature("ios") - if Global.is_mobile(): mobile_ui.show() label_crosshair.show() @@ -404,9 +402,6 @@ func _on_control_menu_request_debug_panel(enabled): func _on_timer_fps_label_timeout(): - var usage_memory_mb: int = int(roundf(OS.get_static_memory_usage() / 1024.0 / 1024.0)) - var usage_peak_memory_mb: int = int(roundf(OS.get_static_memory_peak_usage() / 1024.0 / 1024.0)) - label_ram.set_text("RAM Usage: %d MB (%d MB peak)" % [usage_memory_mb, usage_peak_memory_mb]) label_fps.set_text("ALPHA - " + str(Engine.get_frames_per_second()) + " FPS") if dirty_save_position: dirty_save_position = false diff --git a/lib/src/auth/dcl_player_identity.rs b/lib/src/auth/dcl_player_identity.rs index f04378cb8..39acae11e 100644 --- a/lib/src/auth/dcl_player_identity.rs +++ b/lib/src/auth/dcl_player_identity.rs @@ -303,6 +303,10 @@ impl DclPlayerIdentity { return false; }; + if ephemeral_auth_chain.expired() { + return false; + } + if !local_wallet_bytes.is_empty() { self._update_local_wallet(local_wallet_bytes.as_slice(), ephemeral_auth_chain); true diff --git a/lib/src/auth/ephemeral_auth_chain.rs b/lib/src/auth/ephemeral_auth_chain.rs index 190a906d2..be399f1a3 100644 --- a/lib/src/auth/ephemeral_auth_chain.rs +++ b/lib/src/auth/ephemeral_auth_chain.rs @@ -53,6 +53,10 @@ impl EphemeralAuthChain { pub fn auth_chain(&self) -> &SimpleAuthChain { &self.auth_chain } + + pub fn expired(&self) -> bool { + self.expiration < std::time::SystemTime::now() + } } impl Clone for EphemeralAuthChain {