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