savefiks
@@ -206,12 +206,9 @@ class TribeGenApp
206
206
{
207
207
try
208
208
{
209
const response = await fetch('api/game/list', {
209
const response = await fetch(`api/game/list?userId=${this.currentUser.email}`, {
210
210
method: 'GET',
211
headers: { 'Authorization': `Bearer ${this.currentUser.token}` },
212
body: JSON.stringify({
213
userId: this.currentUser.email
214
})
211
headers: { 'Authorization': `Bearer ${this.currentUser.token}` }
215
212
});
216
213
217
214
const dataText = await response.text();
@@ -865,6 +862,9 @@ class TribeGenApp
865
862
const list = document.getElementById('eventsList');
866
863
list.innerHTML = '';
867
864
865
this.availableEvents = this.availableEvents || [];
866
this.availableEvents = this.availableEvents.filter(evt => !!evt.available);
867
868
868
if (!this.availableEvents || this.availableEvents.length === 0)
869
869
{
870
870
const empty = document.createElement('div');
@@ -206,12 +206,9 @@ class TribeGenApp206
{206
{207
try207
try208
{208
{209
const response = await fetch('api/game/list', {209
const response = await fetch(`api/game/list?userId=${this.currentUser.email}`, {210
method: 'GET',210
method: 'GET',211
headers: { 'Authorization': `Bearer ${this.currentUser.token}` },211
headers: { 'Authorization': `Bearer ${this.currentUser.token}` }212
body: JSON.stringify({213
userId: this.currentUser.email214
})215
});212
});216
213
217
const dataText = await response.text();214
const dataText = await response.text();@@ -865,6 +862,9 @@ class TribeGenApp865
const list = document.getElementById('eventsList');862
const list = document.getElementById('eventsList');866
list.innerHTML = '';863
list.innerHTML = '';867
864
865
this.availableEvents = this.availableEvents || [];866
this.availableEvents = this.availableEvents.filter(evt => !!evt.available);867
868
if (!this.availableEvents || this.availableEvents.length === 0)868
if (!this.availableEvents || this.availableEvents.length === 0)869
{869
{870
const empty = document.createElement('div');870
const empty = document.createElement('div');@@ -16,6 +16,7 @@ if ($method === 'POST') {
16
16
// Generate a simple token (in production use JWT)
17
17
$token = bin2hex(random_bytes(32));
18
18
$_SESSION['user_id'] = $user->getId();
19
$_SESSION['user_email'] = $user->getEmail();
19
20
$_SESSION['token'] = $token;
20
21
21
22
echo json_encode([
@@ -39,7 +40,7 @@ if ($method === 'POST') {
39
40
40
41
$token = bin2hex(random_bytes(32));
41
42
$_SESSION['user_id'] = $user->getId();
42
$_SESSION['token'] = $token;
43
$_SESSION['user_email'] = $user->getEmail();
43
44
44
45
echo json_encode([
45
46
'success' => true,
@@ -16,6 +16,7 @@ if ($method === 'POST') {16
// Generate a simple token (in production use JWT)16
// Generate a simple token (in production use JWT)17
$token = bin2hex(random_bytes(32));17
$token = bin2hex(random_bytes(32));18
$_SESSION['user_id'] = $user->getId();18
$_SESSION['user_id'] = $user->getId();19
$_SESSION['user_email'] = $user->getEmail();19
$_SESSION['token'] = $token;20
$_SESSION['token'] = $token;20
21
21
echo json_encode([22
echo json_encode([@@ -39,7 +40,7 @@ if ($method === 'POST') {39
40
40
$token = bin2hex(random_bytes(32));41
$token = bin2hex(random_bytes(32));41
$_SESSION['user_id'] = $user->getId();42
$_SESSION['user_id'] = $user->getId();42
$_SESSION['token'] = $token;43
$_SESSION['user_email'] = $user->getEmail();43
44
44
echo json_encode([45
echo json_encode([45
'success' => true,46
'success' => true,@@ -564,7 +564,7 @@ if ($method === 'POST') {
564
564
} elseif (strpos($apiPath, 'list') !== false) {
565
565
// List saves for user
566
566
try {
567
$userId = $_GET['userId'] ?? null;
567
$userId = $_SESSION['user_email'] ?? null;
568
568
569
569
if (!$userId) {
570
570
throw new \Exception('Not authenticated');
@@ -564,7 +564,7 @@ if ($method === 'POST') {564
} elseif (strpos($apiPath, 'list') !== false) {564
} elseif (strpos($apiPath, 'list') !== false) {565
// List saves for user565
// List saves for user566
try {566
try {567
$userId = $_GET['userId'] ?? null;567
$userId = $_SESSION['user_email'] ?? null;568
568
569
if (!$userId) {569
if (!$userId) {570
throw new \Exception('Not authenticated');570
throw new \Exception('Not authenticated');