Add password login and collection visibility settings
All checks were successful
Build plugin / build (push) Successful in 1m10s
All checks were successful
Build plugin / build (push) Successful in 1m10s
This commit is contained in:
parent
173aa94ea9
commit
e2a4464d0d
5 changed files with 218 additions and 26 deletions
28
plugin.gd
28
plugin.gd
|
|
@ -16,6 +16,8 @@ var icon := preload("res://plugins/itch/assets/itch.svg")
|
|||
|
||||
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
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -46,15 +48,29 @@ func _on_client_start() -> void:
|
|||
|
||||
# Triggers when butlerd has completed its handshake and is ready for calls
|
||||
func _on_client_ready() -> void:
|
||||
if api_key == "":
|
||||
var notify := Notification.new("itch.io API key required")
|
||||
if login_method == 0:
|
||||
# API key login
|
||||
if api_key == "":
|
||||
var notify := Notification.new("itch.io API key required")
|
||||
notify.icon = icon
|
||||
logger.info(notify.text)
|
||||
notification_manager.show(notify)
|
||||
return
|
||||
itch.login_with_api_key(api_key)
|
||||
else:
|
||||
# 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
|
||||
# Password is not persisted; prompt via settings if needed.
|
||||
# For now, just log the message — the user must save from settings.
|
||||
var notify := Notification.new("itch.io: open plugin settings to log in with username/password")
|
||||
notify.icon = icon
|
||||
logger.info(notify.text)
|
||||
notification_manager.show(notify)
|
||||
return
|
||||
|
||||
# If we have a saved API key, try logging in with it automatically
|
||||
itch.login_with_api_key(api_key)
|
||||
|
||||
|
||||
# Triggers when the itch client finishes a login attempt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue