fix: restore full Godot auth in progressive web build
This commit is contained in:
@@ -696,6 +696,7 @@ func _ready() -> void:
|
||||
_connect_signals()
|
||||
_refresh_appearance_ui()
|
||||
_show_login()
|
||||
_notify_web_shell_ready()
|
||||
|
||||
if _auth_manager != null and bool(_auth_manager.call("is_authenticated")) and _should_auto_resume_cached_session():
|
||||
_resume_cached_session()
|
||||
@@ -741,6 +742,12 @@ func _connect_signals() -> void:
|
||||
if _auth_manager.has_signal("browser_bootstrap_received"):
|
||||
_auth_manager.connect("browser_bootstrap_received", _complete_browser_bootstrap)
|
||||
|
||||
func _notify_web_shell_ready() -> void:
|
||||
if OS.get_name() != "Web" or not Engine.has_singleton("JavaScriptBridge"):
|
||||
return
|
||||
var bridge: Object = Engine.get_singleton("JavaScriptBridge")
|
||||
bridge.eval("window.whaletownGodotReady && window.whaletownGodotReady()", true)
|
||||
|
||||
func _complete_browser_bootstrap(kind: String) -> void:
|
||||
if _is_submitting:
|
||||
return
|
||||
|
||||
@@ -1,40 +1,9 @@
|
||||
extends Control
|
||||
|
||||
var _auth_manager: Node
|
||||
var _scene_manager: Node
|
||||
var _handled: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
_auth_manager = get_node_or_null("/root/AuthManager")
|
||||
_scene_manager = get_node_or_null("/root/SceneManager")
|
||||
if OS.get_name() != "Web":
|
||||
_scene_manager.call_deferred("change_scene", "auth", false)
|
||||
if _scene_manager == null:
|
||||
return
|
||||
if _auth_manager == null:
|
||||
return
|
||||
if _auth_manager.has_signal("browser_bootstrap_received"):
|
||||
_auth_manager.connect("browser_bootstrap_received", _on_browser_bootstrap_received)
|
||||
var kind := str(_auth_manager.call("get_browser_bootstrap_kind")) if _auth_manager.has_method("get_browser_bootstrap_kind") else ""
|
||||
if not kind.is_empty():
|
||||
call_deferred("_on_browser_bootstrap_received", kind)
|
||||
|
||||
func _on_browser_bootstrap_received(kind: String) -> void:
|
||||
if _handled or _scene_manager == null:
|
||||
return
|
||||
_handled = true
|
||||
if kind == "register":
|
||||
_scene_manager.call("change_scene", "auth", false)
|
||||
return
|
||||
if _auth_manager.has_method("consume_browser_bootstrap_kind"):
|
||||
_auth_manager.call("consume_browser_bootstrap_kind")
|
||||
var appearanceManager := get_node_or_null("/root/AppearanceManager")
|
||||
if appearanceManager != null and appearanceManager.has_method("apply_account_profile"):
|
||||
appearanceManager.call("apply_account_profile", _auth_manager.call("get_current_profile"))
|
||||
var chatManager := get_node_or_null("/root/ChatManager")
|
||||
var token := str(_auth_manager.call("get_access_token"))
|
||||
if chatManager != null and not token.is_empty():
|
||||
chatManager.call("set_game_token", token)
|
||||
chatManager.call("connect_to_chat_server")
|
||||
if _auth_manager.has_method("fetch_profile"):
|
||||
_auth_manager.call("fetch_profile")
|
||||
_scene_manager.call("change_scene", "square", false)
|
||||
_scene_manager.call_deferred("change_scene", "auth", false)
|
||||
|
||||
Reference in New Issue
Block a user