From 9c5c49b83c76da8240cf1448b5b27144348d891a Mon Sep 17 00:00:00 2001 From: Orestis Moresis Date: Thu, 7 Dec 2023 12:35:08 +0200 Subject: [PATCH] fix guest user login by creating new group as public --- src/Controllers/AuthController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index 6614a49..9ab604b 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -52,7 +52,7 @@ class AuthController { public function guestSignin() { - header('Location: /'); + // header('Location: /'); // Prevent invalid email input $email = $_POST['username']; @@ -78,6 +78,8 @@ class AuthController { $_SESSION['user_name'] = "Guest"; $_SESSION['user_id'] = self::insertGuestUser($email); + $s = self::insertGuestGroup($_SESSION['user_id']); + header('HTTP/1.1 302 Found'); header('Location: /'); exit(0); @@ -108,6 +110,13 @@ class AuthController { return json_decode(PgSql::insert($sql, 'geo_id'))->geo_id; } + + private function insertGuestGroup($id) { + $sql = "INSERT INTO webapp.users__groups (user_id, group_id) + VALUES ('${id}', 1) ON CONFLICT DO NOTHING"; + + PgSql::insert($sql, 'NULL'); + } }