İlk commit: Stepstead Godot istemci (4.6 Mobile)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jts 2026-07-11 11:31:35 +03:00
commit 6a1706051d
346 changed files with 14415 additions and 0 deletions

53
autoload/auth.gd Normal file
View file

@ -0,0 +1,53 @@
extends Node
## Auth durumu — JWT token saklama ve auth API çağrıları.
const SAVE_PATH := "user://auth.dat"
var token: String = ""
var user: Dictionary = {}
func _ready() -> void:
_load()
func _save() -> void:
var f := FileAccess.open(SAVE_PATH, FileAccess.WRITE)
if f:
f.store_var({"token": token, "user": user})
func _load() -> void:
if not FileAccess.file_exists(SAVE_PATH):
return
var f := FileAccess.open(SAVE_PATH, FileAccess.READ)
if f:
var data: Variant = f.get_var()
if data is Dictionary:
token = data.get("token", "")
user = data.get("user", {})
func is_logged_in() -> bool:
return token != ""
func clear() -> void:
token = ""
user = {}
_save()
func register(email: String, password: String, display_name: String = "") -> Dictionary:
var body := {"email": email, "password": password}
if display_name != "":
body["display_name"] = display_name
return await Api.request("POST", "/auth/register", body, false)
func login(email: String, password: String) -> Dictionary:
var res: Dictionary = await Api.request("POST", "/auth/login", {"email": email, "password": password}, false)
if res.ok and res.body is Dictionary and res.body.has("access_token"):
token = res.body["access_token"]
_save()
var me_res: Dictionary = await Api.request("GET", "/auth/me", null, true)
if me_res.ok:
user = me_res.body
_save()
return res
func request_password_reset(email: String) -> Dictionary:
return await Api.request("POST", "/auth/request-password-reset", {"email": email}, false)