|
|
|
@ -24,12 +24,12 @@ class AuthController {
@@ -24,12 +24,12 @@ class AuthController {
|
|
|
|
|
|
|
|
|
|
// Handle guest login |
|
|
|
|
if (!isset($_POST['password'])) { |
|
|
|
|
$_SESSION['user_id'] = guidv4($email); |
|
|
|
|
$_SESSION['user_groups'] = [1]; |
|
|
|
|
$_SESSION['user_name'] = "Guest"; |
|
|
|
|
$_SESSION['user_id'] = self::insertGuestUser($email); |
|
|
|
|
/* header('HTTP/1.1 302 Found'); */ |
|
|
|
|
header('Location: /home'); |
|
|
|
|
/* return TRUE; */ |
|
|
|
|
header('Location: /'); |
|
|
|
|
return TRUE; |
|
|
|
|
} else { // handle user login |
|
|
|
|
$email = $_POST['username']; |
|
|
|
|
$password = $_POST['password']; |
|
|
|
@ -85,6 +85,17 @@ class AuthController {
@@ -85,6 +85,17 @@ class AuthController {
|
|
|
|
|
exit(); |
|
|
|
|
/* header('Refresh: 2; URL = index.php'); */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function insertGuestUser($email) { |
|
|
|
|
$uid = guidv4($email); |
|
|
|
|
$sql = "INSERT INTO webapp.users (email, password, origin, geo_id) |
|
|
|
|
VALUES ('${email}', '', 'GUEST', '${uid}') |
|
|
|
|
ON CONFLICT (email) DO UPDATE |
|
|
|
|
SET geo_id = EXCLUDED.geo_id, |
|
|
|
|
last_login = now()"; |
|
|
|
|
return json_decode(PgSql::insert($sql, 'geo_id'))->geo_id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|