|
|
@ -24,12 +24,12 @@ class AuthController { |
|
|
|
|
|
|
|
|
|
|
|
// Handle guest login |
|
|
|
// Handle guest login |
|
|
|
if (!isset($_POST['password'])) { |
|
|
|
if (!isset($_POST['password'])) { |
|
|
|
$_SESSION['user_id'] = guidv4($email); |
|
|
|
|
|
|
|
$_SESSION['user_groups'] = [1]; |
|
|
|
$_SESSION['user_groups'] = [1]; |
|
|
|
$_SESSION['user_name'] = "Guest"; |
|
|
|
$_SESSION['user_name'] = "Guest"; |
|
|
|
|
|
|
|
$_SESSION['user_id'] = self::insertGuestUser($email); |
|
|
|
/* header('HTTP/1.1 302 Found'); */ |
|
|
|
/* header('HTTP/1.1 302 Found'); */ |
|
|
|
header('Location: /home'); |
|
|
|
header('Location: /'); |
|
|
|
/* return TRUE; */ |
|
|
|
return TRUE; |
|
|
|
} else { // handle user login |
|
|
|
} else { // handle user login |
|
|
|
$email = $_POST['username']; |
|
|
|
$email = $_POST['username']; |
|
|
|
$password = $_POST['password']; |
|
|
|
$password = $_POST['password']; |
|
|
@ -85,6 +85,17 @@ class AuthController { |
|
|
|
exit(); |
|
|
|
exit(); |
|
|
|
/* header('Refresh: 2; URL = index.php'); */ |
|
|
|
/* 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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|