Browse Source

fix guest user login by creating new group as public

master
o.moresis 1 year ago
parent
commit
9c5c49b83c
  1. 11
      src/Controllers/AuthController.php

11
src/Controllers/AuthController.php

@ -52,7 +52,7 @@ class AuthController { @@ -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 { @@ -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 { @@ -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');
}
}

Loading…
Cancel
Save