Skip to content

Commit

Permalink
fix: check if auth chain is expired on restoring the session (#444)
Browse files Browse the repository at this point in the history
fix: change open browser text when magic is not presented
  • Loading branch information
kuruk-mm authored Aug 19, 2024
1 parent 6540ef3 commit 17cfaeb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion godot/src/ui/components/auth/lobby.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions godot/src/ui/components/auth/lobby.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion godot/src/ui/components/auth/magic_login.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions godot/src/ui/explorer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/src/auth/dcl_player_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/src/auth/ephemeral_auth_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 17cfaeb

Please sign in to comment.