From d97dbaa20f91953afb95c31486b754586116b582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Fri, 10 Aug 2018 14:57:58 +0900 Subject: [PATCH] Add: session storage manager - maestroAccountType, playerAccountType --- src/game/global/global_variables.js | 2 ++ src/game/lib/session_storage_manager.js | 16 +++++++++ src/game/login/login.js | 2 ++ src/web/client/menu_app_test_player.html | 17 ++++----- src/web/module/maestro_header.html | 14 +++----- src/web/module/maestro_section_login.html | 4 +-- src/web/server/maestro/login.php | 6 ++-- .../server/maestro/maestro_test_player.php | 34 +++++++++++------- src/web/server/player/login.php | 35 ++++++++++++------- 9 files changed, 83 insertions(+), 47 deletions(-) diff --git a/src/game/global/global_variables.js b/src/game/global/global_variables.js index ec7ebd6..fcc6c55 100644 --- a/src/game/global/global_variables.js +++ b/src/game/global/global_variables.js @@ -32,8 +32,10 @@ let sessionStorageManager = new SessionStorageManager(); // } console.log("maestroID : " + sessionStorageManager.maestroID); + console.log("maestroAccountType : " + sessionStorageManager.maestroAccountType); console.log("playerName : " + sessionStorageManager.playerName); console.log("playerID : " + sessionStorageManager.playerID); + console.log("playerAccountType : " + sessionStorageManager.playerAccountType); console.log("playingAppID : " + sessionStorageManager.playingAppID); console.log("playingAppName : " + sessionStorageManager.playingAppName); console.log("playingAppKoreanName : " + sessionStorageManager.playingAppKoreanName); diff --git a/src/game/lib/session_storage_manager.js b/src/game/lib/session_storage_manager.js index 4b43083..3396c6e 100644 --- a/src/game/lib/session_storage_manager.js +++ b/src/game/lib/session_storage_manager.js @@ -19,6 +19,14 @@ class SessionStorageManager { return sessionStorage.getItem("maestroID"); } + // maestro account type + set maestroAccountType(value) { + sessionStorage.setItem("maestroAccountType", value); + } + get maestroAccountType() { + return sessionStorage.getItem("maestroAccountType"); + } + // player name set playerName(value) { sessionStorage.setItem("playerName", value); @@ -35,6 +43,14 @@ class SessionStorageManager { return sessionStorage.getItem("playerID"); } + // player account type + set playerAccountType(value) { + sessionStorage.setItem("playerAccountType", value); + } + get playerAccountType() { + return sessionStorage.getItem("playerAccountType"); + } + // playing app id set playingAppID(value) { sessionStorage.setItem("playingAppID", value); diff --git a/src/game/login/login.js b/src/game/login/login.js index 7370523..1ac4f33 100644 --- a/src/game/login/login.js +++ b/src/game/login/login.js @@ -101,7 +101,9 @@ class Login { loginSucceeded(jsonData) { sessionStorageManager.maestroID = jsonData['MaestroID']; + sessionStorageManager.maestroAccountType = jsonData['MaestroAccountType']; sessionStorageManager.playerID = jsonData['PlayerID']; + sessionStorageManager.playerAccountType = jsonData['PlayerAccountType']; sessionStorageManager.playingAppName = "menu"; location.href = '../../web/client/menu_app.html'; diff --git a/src/web/client/menu_app_test_player.html b/src/web/client/menu_app_test_player.html index 9095090..7fedd64 100644 --- a/src/web/client/menu_app_test_player.html +++ b/src/web/client/menu_app_test_player.html @@ -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) => { diff --git a/src/web/module/maestro_header.html b/src/web/module/maestro_header.html index 966fe36..a47da69 100644 --- a/src/web/module/maestro_header.html +++ b/src/web/module/maestro_header.html @@ -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"); } diff --git a/src/web/module/maestro_section_login.html b/src/web/module/maestro_section_login.html index 5b4aa56..4782490 100644 --- a/src/web/module/maestro_section_login.html +++ b/src/web/module/maestro_section_login.html @@ -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'; }, diff --git a/src/web/server/maestro/login.php b/src/web/server/maestro/login.php index 37fe4df..99c8ae7 100644 --- a/src/web/server/maestro/login.php +++ b/src/web/server/maestro/login.php @@ -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; diff --git a/src/web/server/maestro/maestro_test_player.php b/src/web/server/maestro/maestro_test_player.php index 2f079f7..1fdb8e4 100644 --- a/src/web/server/maestro/maestro_test_player.php +++ b/src/web/server/maestro/maestro_test_player.php @@ -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; } ?> \ No newline at end of file diff --git a/src/web/server/player/login.php b/src/web/server/player/login.php index 69e5087..92a6da6 100644 --- a/src/web/server/player/login.php +++ b/src/web/server/player/login.php @@ -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; } ?> \ No newline at end of file