|
|
@ -52,8 +52,6 @@ class AuthController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function guestSignin() { |
|
|
|
public function guestSignin() { |
|
|
|
// header('Location: /'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Prevent invalid email input |
|
|
|
// Prevent invalid email input |
|
|
|
$email = $_POST['username']; |
|
|
|
$email = $_POST['username']; |
|
|
|
if (!valid_email($email)) { |
|
|
|
if (!valid_email($email)) { |
|
|
@ -72,6 +70,12 @@ class AuthController { |
|
|
|
exit(400); |
|
|
|
exit(400); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!self::isEmail($email)) { |
|
|
|
|
|
|
|
header('HTTP/1.1 422 Unprocessable Entity'); |
|
|
|
|
|
|
|
header('Location: login'); |
|
|
|
|
|
|
|
exit(422); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Handle guest login |
|
|
|
// Handle guest login |
|
|
|
if (isset($_POST['username'])) { |
|
|
|
if (isset($_POST['username'])) { |
|
|
|
$_SESSION['user_groups'] = [1]; |
|
|
|
$_SESSION['user_groups'] = [1]; |
|
|
@ -99,16 +103,19 @@ class AuthController { |
|
|
|
exit(); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function isEmail($email) { |
|
|
|
|
|
|
|
return filter_var($email, FILTER_VALIDATE_EMAIL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function insertGuestUser($email) { |
|
|
|
private function insertGuestUser($email) { |
|
|
|
$uid = guidv4($email); |
|
|
|
$sql = "INSERT INTO webapp.users (email, origin, password) |
|
|
|
$sql = "INSERT INTO webapp.users (email, password, origin, geo_id) |
|
|
|
VALUES ('${email}', 'GUEST', '') |
|
|
|
VALUES ('${email}', '', 'GUEST', '${uid}') |
|
|
|
|
|
|
|
ON CONFLICT (email) DO UPDATE |
|
|
|
ON CONFLICT (email) DO UPDATE |
|
|
|
SET geo_id = EXCLUDED.geo_id, |
|
|
|
SET last_login = now()"; |
|
|
|
last_login = now()"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return json_decode(PgSql::insert($sql, 'geo_id'))->geo_id; |
|
|
|
$res = PgSql::insert($sql, 'geo_id'); |
|
|
|
|
|
|
|
return json_decode($res)->geo_id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function insertGuestGroup($id) { |
|
|
|
private function insertGuestGroup($id) { |
|
|
|