Replace cookie HTTP verification with butlerd's Profile.List + UseSavedLogin
Some checks failed
Build plugin / build (push) Has been cancelled
Some checks failed
Build plugin / build (push) Has been cancelled
Butlerd stores credentials in its SQLite DB after the first password login. On restart, Profile.List finds saved profiles and Profile.UseSavedLogin refreshes them — no cookie persistence needed on our side.
This commit is contained in:
parent
1931ae143a
commit
d09bd2ae79
3 changed files with 37 additions and 114 deletions
24
plugin.gd
24
plugin.gd
|
|
@ -18,7 +18,6 @@ var itch: ItchClient
|
|||
var api_key := settings_manager.get_value("plugin.itch", "api_key", "") as String
|
||||
var login_method := settings_manager.get_value("plugin.itch", "login_method", 0) as int
|
||||
var username := settings_manager.get_value("plugin.itch", "username", "") as String
|
||||
var saved_cookie := settings_manager.get_value("plugin.itch", "cookie", "") as String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -30,7 +29,6 @@ func _ready() -> void:
|
|||
itch.bootstrap_finished.connect(_on_client_start)
|
||||
itch.client_ready.connect(_on_client_ready)
|
||||
itch.logged_in.connect(_on_client_logged_in)
|
||||
itch.login_cookies_saved.connect(_on_cookies_saved)
|
||||
add_child(itch)
|
||||
|
||||
# Load the Library implementation
|
||||
|
|
@ -50,6 +48,10 @@ func _on_client_start() -> void:
|
|||
|
||||
# Triggers when butlerd has completed its handshake and is ready for calls
|
||||
func _on_client_ready() -> void:
|
||||
# Always try butlerd's stored credentials first — this handles password
|
||||
# logins from previous runs without any stored tokens on our side.
|
||||
if await itch.try_saved_login():
|
||||
return
|
||||
if login_method == 0:
|
||||
# API key login
|
||||
if api_key == "":
|
||||
|
|
@ -60,20 +62,17 @@ func _on_client_ready() -> void:
|
|||
return
|
||||
itch.login_with_api_key(api_key)
|
||||
else:
|
||||
# Username/password login — try saved cookie first.
|
||||
# Username/password login
|
||||
if username == "":
|
||||
var notify := Notification.new("itch.io username required")
|
||||
notify.icon = icon
|
||||
logger.info(notify.text)
|
||||
notification_manager.show(notify)
|
||||
return
|
||||
if saved_cookie != "":
|
||||
itch.login_with_cookie(saved_cookie)
|
||||
else:
|
||||
var notify := Notification.new("itch.io: open plugin settings to log in")
|
||||
notify.icon = icon
|
||||
logger.info(notify.text)
|
||||
notification_manager.show(notify)
|
||||
var notify := Notification.new("itch.io: open plugin settings to log in")
|
||||
notify.icon = icon
|
||||
logger.info(notify.text)
|
||||
notification_manager.show(notify)
|
||||
|
||||
|
||||
# Triggers when the itch client finishes a login attempt
|
||||
|
|
@ -93,11 +92,6 @@ func _on_client_logged_in(status: ItchClient.LOGIN_STATUS, profile: Dictionary)
|
|||
notification_manager.show(notify)
|
||||
|
||||
|
||||
func _on_cookies_saved(uname: String, cookie: String) -> void:
|
||||
settings_manager.set_value("plugin.itch", "username", uname)
|
||||
settings_manager.set_value("plugin.itch", "cookie", cookie)
|
||||
|
||||
|
||||
# Return the settings menu scene
|
||||
func get_settings_menu() -> Control:
|
||||
return settings_menu.instantiate()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue