This commit is contained in:
Austin 2021-11-12 13:32:40 -05:00
parent 0161c7c639
commit 138f2f0f14
4 changed files with 66 additions and 0 deletions

View File

@ -5259,6 +5259,10 @@ function deleteUser2FA($userid)
$del = $GLOBALS['pdo']->prepare("DELETE FROM `google_2fa` WHERE `userid` = :uid");
$del->bindParam(":uid", $userid, PDO::PARAM_INT);
$del->execute();
if ($del->rowCount() > 0) {
return true;
}
return false;
}
function getUser2FASecret($userid)
@ -5325,6 +5329,17 @@ function initialize2FA($userid)
}
}
function getUser2FAQR($userid)
{
$qrcode = $GLOBALS['pdo']->prepare("SELECT * FROM `google_2fa` WHERE `userid` = :uid");
$qrcode->bindParam(":uid", $userid, PDO::PARAM_INT);
$qrcode->execute();
if ($qrcode->rowCount() > 0) {
return $qrcode->fetch(PDO::FETCH_OBJ)->qr;
}
}
function setBlurb($newblurb)

View File

@ -0,0 +1,23 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
$userid = $user->id;
$data = json_decode(file_get_contents('php://input'));
if (!$data)
{
http_response_code(400);
}
else
{
$code = $data->code;
header('Content-Type: application/json');
echo json_encode(array("success" => activateUser2FA($userid, $code)));
}

View File

@ -0,0 +1,13 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
$userid = $user->id;
echo json_encode(array("success" => deleteUser2FA($userid)));

View File

@ -0,0 +1,15 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
$userid = $user->id;
die(json_encode(["qr"=>getUser2FAQR($userid)]));