Add legal consent and reliable external redirects
This commit is contained in:
@@ -22,6 +22,11 @@ var expires_at := ""
|
||||
var expiration_unix := 0.0
|
||||
var refresh_in_progress := false
|
||||
var warning_active := false
|
||||
var requires_legal_acceptance := false
|
||||
var terms_version := ""
|
||||
var privacy_version := ""
|
||||
var terms_url := ""
|
||||
var privacy_url := ""
|
||||
var auth_base_url := DEFAULT_AUTH_BASE_URL
|
||||
var expiry_timer: Timer
|
||||
var refresh_request: HTTPRequest
|
||||
@@ -42,7 +47,7 @@ func _ready() -> void:
|
||||
refresh_request.request_completed.connect(_on_refresh_completed)
|
||||
add_child(refresh_request)
|
||||
|
||||
func set_session(new_username: String, token: String, new_refresh_token: String = "", new_role: String = "", token_expiration: String = "") -> void:
|
||||
func set_session(new_username: String, token: String, new_refresh_token: String = "", new_role: String = "", token_expiration: String = "", legal: Dictionary = {}) -> void:
|
||||
session_revision += 1
|
||||
is_logged_in = not token.is_empty()
|
||||
username = new_username
|
||||
@@ -54,6 +59,7 @@ func set_session(new_username: String, token: String, new_refresh_token: String
|
||||
refresh_in_progress = false
|
||||
refresh_revision = -1
|
||||
warning_active = false
|
||||
set_legal_state(legal, false)
|
||||
if is_logged_in and expiration_unix > 0.0:
|
||||
expiry_timer.start()
|
||||
else:
|
||||
@@ -63,6 +69,16 @@ func set_session(new_username: String, token: String, new_refresh_token: String
|
||||
_evaluate_expiry.call_deferred()
|
||||
|
||||
|
||||
func set_legal_state(legal: Dictionary, notify := true) -> void:
|
||||
requires_legal_acceptance = bool(legal.get("requiresLegalAcceptance", false))
|
||||
terms_version = str(legal.get("termsVersion", terms_version))
|
||||
privacy_version = str(legal.get("privacyVersion", privacy_version))
|
||||
terms_url = str(legal.get("termsUrl", terms_url))
|
||||
privacy_url = str(legal.get("privacyUrl", privacy_url))
|
||||
if notify:
|
||||
auth_changed.emit()
|
||||
|
||||
|
||||
func clear_session() -> void:
|
||||
_clear_session_fields()
|
||||
auth_changed.emit()
|
||||
@@ -175,6 +191,9 @@ func _on_refresh_completed(result: int, response_code: int, _headers: PackedStri
|
||||
expires_at = new_expiration
|
||||
expiration_unix = new_expiration_unix
|
||||
warning_active = false
|
||||
var legal_value: Variant = parsed.get("legal", {})
|
||||
if typeof(legal_value) == TYPE_DICTIONARY:
|
||||
set_legal_state(legal_value, false)
|
||||
session_revision += 1
|
||||
expiry_timer.start()
|
||||
auth_changed.emit()
|
||||
@@ -197,6 +216,11 @@ func _clear_session_fields() -> void:
|
||||
refresh_in_progress = false
|
||||
refresh_revision = -1
|
||||
warning_active = false
|
||||
requires_legal_acceptance = false
|
||||
terms_version = ""
|
||||
privacy_version = ""
|
||||
terms_url = ""
|
||||
privacy_url = ""
|
||||
|
||||
|
||||
func _parse_expiration(value: String, token: String = "") -> float:
|
||||
|
||||
Reference in New Issue
Block a user