Add: session storage manager - maestroAccountType, playerAccountType

This commit is contained in:
2018-08-10 14:57:58 +09:00
parent ade28a3334
commit d97dbaa20f
9 changed files with 83 additions and 47 deletions
+9 -8
View File
@@ -18,16 +18,17 @@
"maestro_id=" + maestroID,
(jsonData) => {
let playerID = jsonData["playerID"];
let playerName = jsonData["playerName"];
console.log("maestroAccountType : " + jsonData["maestroAccountType"]);
console.log("playerName : " + jsonData["playerName"]);
console.log("playerID : " + jsonData["playerID"]);
console.log("playerAccountType : " + jsonData["playerAccountType"]);
console.log("playerID : " + playerID);
console.log("playerName : " + playerName);
sessionStorage.setItem("maestroAccountType", jsonData["maestroAccountType"]);
sessionStorage.setItem("playerID", jsonData["playerID"]);
sessionStorage.setItem("playerName", jsonData["playerName"]);
sessionStorage.setItem("playerAccountType", jsonData["playerAccountType"]);
sessionStorage.setItem("playerID", playerID);
sessionStorage.setItem("playerName", playerName);
location.href='./../client/menu_app.html';
// location.href='./../client/menu_app.html';
},
(errorMessage, errorCode) => {
+4 -10
View File
@@ -6,14 +6,10 @@ function loadMaestroTestAccountInfo() {
"maestro_id=" + maestroID,
(jsonData) => {
let playerID = jsonData["playerID"];
let playerName = jsonData["playerName"];
console.log("playerID : " + playerID);
console.log("playerName : " + playerName);
sessionStorage.setItem("playerID", playerID);
sessionStorage.setItem("playerName", playerName);
// console.log("playerID : " + jsonData["playerID"]);
// console.log("playerName : " + jsonData["playerName"]);
sessionStorage.setItem("playerID", jsonData["playerID"]);
sessionStorage.setItem("playerName", jsonData["playerName"]);
},
(errorMessage, errorCode) => {
@@ -27,8 +23,6 @@ function loadMaestroTestAccountInfo() {
function runMaestroAccountApp() {
loadMaestroTestAccountInfo();
// window.open("./../client/menu_app.html", "_blank");
// menu_app_test_player
window.open("./../client/menu_app_test_player.html", "_blank");
}
+2 -2
View File
@@ -28,8 +28,8 @@ function login() {
"maestro_name=" + name + "&password=" + password,
(jsonData) => {
maestroID = jsonData["maestroID"];
sessionStorage.setItem("maestroID", maestroID);
sessionStorage.setItem("maestroID", jsonData["maestroID"]);
sessionStorage.setItem("maestroAccountType", jsonData["maestroAccountType"]);
location.href = './../maestro/main_menu.html';
},
+4 -2
View File
@@ -44,6 +44,7 @@ if($loginData === null) {
}
set_data("maestroID", $loginData[maestroID]);
set_data("maestroAccountType", $loginData[accountType]);
set_data("activateStatus", $loginData[activateStatus]);
set_data("availableActivateDateTime", $loginData[availableActivateDateTime]);
send_result_success();
@@ -76,19 +77,20 @@ function login($maestroName, $password) {
global $db_conn;
$query = "
SELECT MaestroID, ActivateStatus, AvailableActivateDateTime
SELECT MaestroID, AccountType, ActivateStatus, AvailableActivateDateTime
FROM moty_maestro
WHERE Name = ? AND Password = PASSWORD(?)
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ss", $maestroName, $password);
$stmt->execute();
$stmt->bind_result($maestroID, $activateStatus, $availableActivateDateTime);
$stmt->bind_result($maestroID, $accountType, $activateStatus, $availableActivateDateTime);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
$result["maestroID"] = $maestroID;
$result["maestroAccountType"] = $accountType;
$result["activateStatus"] = $activateStatus;
$result["availableActivateDateTime"] = $availableActivateDateTime;
return $result;
+22 -12
View File
@@ -7,17 +7,19 @@ include "./../setup/connect_db.php";
$maestro_id = $_POST["maestro_id"];
$maestro_test_player_id = get_maestro_test_player_id($maestro_id);
if($maestro_test_player_id === null) {
$maestroInfo = get_maestro_test_player_id($maestro_id);
if($maestroInfo === null) {
set_error_message("등록된 마에스트로 테스트 계정이 없습니다");
send_result_fail();
exit;
}
$maestro_test_player_name = get_maestro_test_player_name($maestro_test_player_id);
$maestroTestPlayerInfo = get_maestro_test_player_info($maestroInfo["maestroTestID"]);
set_data("playerID", $maestro_test_player_id);
set_data("playerName", $maestro_test_player_name);
set_data("maestroAccountType", $maestroInfo["accountType"]);
set_data("playerID", $maestroInfo["maestroTestID"]);
set_data("playerName", $maestroTestPlayerInfo["Name"]);
set_data("playerAccountType", $maestroTestPlayerInfo["AccountType"]);
send_result_success();
exit;
@@ -27,38 +29,46 @@ function get_maestro_test_player_id($maestro_id) {
global $db_conn;
$query = "
SELECT MaestroTestID
SELECT AccountType, MaestroTestID
FROM moty_maestro
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_id);
$stmt->bind_result($accountType, $maestroTestID);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_id;
$result["accountType"] = $accountType;
$result["maestroTestID"] = $maestroTestID;
return $result;
}
function get_maestro_test_player_name($player_id) {
function get_maestro_test_player_info($player_id) {
global $db_conn;
$query = "SELECT Name FROM moty_player WHERE PlayerID=?";
$query = "
SELECT Name, AccountType
FROM moty_player
WHERE PlayerID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $player_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_name);
$stmt->bind_result($name, $accountType);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_name;
$result["Name"] = $name;
$result["AccountType"] = $accountType;
return $result;
}
?>
+22 -13
View File
@@ -9,23 +9,31 @@ $name = $_POST["name"];
$enterCode = $_POST["enter_code"];
$maestroID = get_maestro_id($maestroName);
if($maestroID === null) {
$maestroInfo = get_maestro_id($maestroName);
if($maestroInfo === null) {
send_error_message($replyJSON, "입력한 마에스트로 계정이 없습니다");
$db_conn->close();
exit;
}
$playerID = get_login_data($maestroID, $name, $enterCode);
if($playerID === null) {
$maestroID = $maestroInfo["maestroID"];
$maestroAccountType = $maestroInfo["accountType"];
$playerInfo = get_login_data($maestroID, $name, $enterCode);
if($playerInfo === null) {
send_error_message($replyJSON, "입력한 이름/입장번호와 일치하는 계정이 없습니다");
$db_conn->close();
exit;
}
$playerID = $playerInfo["playerID"];
$playerAccountType = $playerInfo["accountType"];
set_data("MaestroID", $maestroID);
set_data("MaestroAccountType", $maestroAccountType);
set_data("PlayerID", $playerID);
set_data("PlayerAccountType", $playerAccountType);
send_result_success();
exit;
@@ -34,43 +42,44 @@ function get_maestro_id($maestroName) {
global $db_conn;
$query = "
SELECT MaestroID
SELECT MaestroID, AccountType
FROM moty_maestro
WHERE Name = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('s', $maestroName);
$stmt->execute();
$stmt->bind_result($maestroID);
$stmt->bind_result($maestroID, $accountType);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestroID;
$result["maestroID"] = $maestroID;
$result["accountType"] = $accountType;
return $result;
}
function get_login_data($maestroID, $name, $enterCode) {
global $db_conn;
$query = "
SELECT PlayerID
SELECT PlayerID, AccountType
FROM moty_player
WHERE MaestroID = ? AND Name = ? AND EnterCode = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iss', $maestroID, $name, $enterCode);
$stmt->execute();
$stmt->bind_result($playerID);
$stmt->bind_result($playerID, $accountType);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
// $replyJSON["MaestroID"] = $maestroID;
// $replyJSON["PlayerID"] = $playerID;
return $playerID;
$result["playerID"] = $playerID;
$result["accountType"] = $accountType;
return $result;
}
?>