Add: MaestroID for login
This commit is contained in:
@@ -47,7 +47,7 @@ class DBConnectManager {
|
|||||||
return "../";
|
return "../";
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCheckUserLogin(userName, enterCode, onSucceededListener, onFailedListener) {
|
requestCheckUserLogin(maestroName, userName, enterCode, onSucceededListener, onFailedListener) {
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", this.phpPath + "server/user/login.php", true);
|
xhr.open("POST", this.phpPath + "server/user/login.php", true);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
@@ -61,7 +61,7 @@ class DBConnectManager {
|
|||||||
onFailedListener(jsonData);
|
onFailedListener(jsonData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send("name=" + userName + "&enter_code=" + enterCode);
|
xhr.send("maestro_name=" + maestroName + "&name=" + userName + "&enter_code=" + enterCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPlayerHistory(date, listener) {
|
requestPlayerHistory(date, listener) {
|
||||||
|
|||||||
+40
-34
@@ -8,7 +8,7 @@ class Login {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
self = this;
|
this.textStyle = { font: "bold 32px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "middle" };
|
||||||
|
|
||||||
sessionStorageManager.clear();
|
sessionStorageManager.clear();
|
||||||
|
|
||||||
@@ -21,53 +21,56 @@ class Login {
|
|||||||
|
|
||||||
let fullscreenButton = new FullscreenButton(this.game);
|
let fullscreenButton = new FullscreenButton(this.game);
|
||||||
|
|
||||||
this.makeInputTypeTexts();
|
let textX = this.game.world.centerX - 360;
|
||||||
|
if(sessionStorageManager.maestroID === null)
|
||||||
|
this.makeMaestroNameText(textX, 240);
|
||||||
|
this.makeNameText(textX, 340);
|
||||||
|
this.makeEnterCodeText(textX, 400);
|
||||||
|
|
||||||
|
|
||||||
|
this.inputTextName.canvasInput.focus();
|
||||||
|
|
||||||
this.makeButton();
|
this.makeButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
makeInputTypeTexts() {
|
makeMaestroNameText(x, y) {
|
||||||
// name
|
this.makeTextField(x, y, "마에스트로 계정 :");
|
||||||
let textX = this.game.world.centerX - 360;
|
this.inputTextMaestroName = this.makeInputTypeText(x, y, "jisangs");
|
||||||
let inputX = this.game.world.centerX + 60;
|
}
|
||||||
let nameTextY = 340;
|
|
||||||
game.add.text(textX, nameTextY, "이름 :", textStyleBasic)
|
makeNameText(x, y) {
|
||||||
|
this.makeTextField(x, y, "이름 :");
|
||||||
|
this.inputTextName = this.makeInputTypeText(x, y, "박지상");
|
||||||
|
}
|
||||||
|
|
||||||
|
makeEnterCodeText(x, y) {
|
||||||
|
this.makeTextField(x, y, "생년월일 :");
|
||||||
|
this.inputTextEnterCode = this.makeInputTypeText(x, y, "760621");
|
||||||
|
}
|
||||||
|
|
||||||
|
makeTextField(x, y, text) {
|
||||||
|
return game.add.text(x, y, text, this.textStyle)
|
||||||
.setTextBounds(0, 0, 200, 0)
|
.setTextBounds(0, 0, 200, 0)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||||
.boundsAlignH = 'right';
|
.boundsAlignH = 'right';
|
||||||
|
}
|
||||||
|
|
||||||
this.inputTextName = new InputTypeText(inputX, nameTextY);
|
makeInputTypeText(x, y, text) {
|
||||||
this.inputTextName.anchor.set(0.5);
|
self = this;
|
||||||
this.inputTextName.canvasInput.value('');
|
|
||||||
|
let inputText = new InputTypeText(x + 420, y);
|
||||||
|
inputText.anchor.set(0.5);
|
||||||
|
inputText.canvasInput.value('');
|
||||||
if(isDebugMode()) {
|
if(isDebugMode()) {
|
||||||
this.inputTextName.canvasInput.value('박지상');
|
inputText.canvasInput.value(text);
|
||||||
}
|
}
|
||||||
this.inputTextName.canvasInput._onkeyup = function() {
|
inputText.canvasInput._onkeyup = function() {
|
||||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||||
self.startMenu();
|
self.startMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// birthday
|
return inputText;
|
||||||
const birthdayTextY = 400;
|
|
||||||
game.add.text(textX, birthdayTextY, "생년월일 :", textStyleBasic)
|
|
||||||
.setTextBounds(0, 0, 200, 0)
|
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
|
||||||
.boundsAlignH = 'right';
|
|
||||||
|
|
||||||
this.inputTextEnterCode = new InputTypeText(inputX, birthdayTextY);
|
|
||||||
this.inputTextEnterCode.anchor.set(0.5);
|
|
||||||
this.inputTextEnterCode.canvasInput.value('');
|
|
||||||
if(isDebugMode()) {
|
|
||||||
this.inputTextEnterCode.canvasInput.value('760621');
|
|
||||||
}
|
|
||||||
this.inputTextEnterCode.canvasInput._onkeyup = function() {
|
|
||||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
|
||||||
self.startMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.inputTextName.canvasInput.focus();
|
|
||||||
// this.inputTextEnterCode.canvasInput.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
makeButton() {
|
makeButton() {
|
||||||
@@ -79,11 +82,13 @@ class Login {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startMenu() {
|
startMenu() {
|
||||||
|
let maestroName = self.inputTextMaestroName.canvasInput._value;
|
||||||
sessionStorageManager.playerName = self.inputTextName.canvasInput._value;
|
sessionStorageManager.playerName = self.inputTextName.canvasInput._value;
|
||||||
let enterCode = self.inputTextEnterCode.canvasInput._value;
|
let enterCode = self.inputTextEnterCode.canvasInput._value;
|
||||||
|
|
||||||
let dbConnectManager = new DBConnectManager();
|
let dbConnectManager = new DBConnectManager();
|
||||||
dbConnectManager.requestCheckUserLogin(
|
dbConnectManager.requestCheckUserLogin(
|
||||||
|
maestroName,
|
||||||
sessionStorageManager.playerName,
|
sessionStorageManager.playerName,
|
||||||
enterCode,
|
enterCode,
|
||||||
self.loginSucceeded,
|
self.loginSucceeded,
|
||||||
@@ -92,6 +97,7 @@ class Login {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginSucceeded(jsonData) {
|
loginSucceeded(jsonData) {
|
||||||
|
sessionStorageManager.maestroID = jsonData['MaestroID'];
|
||||||
sessionStorageManager.playerUserID = jsonData['UserID'];
|
sessionStorageManager.playerUserID = jsonData['UserID'];
|
||||||
|
|
||||||
sessionStorageManager.playingAppName = "menu";
|
sessionStorageManager.playingAppName = "menu";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
|
|||||||
|
|
||||||
include "./../send_error_code.php";
|
include "./../send_error_code.php";
|
||||||
|
|
||||||
|
$maestro_name = $_POST["maestro_name"];
|
||||||
$name = $_POST["name"];
|
$name = $_POST["name"];
|
||||||
$enterCode = $_POST["enter_code"];
|
$enterCode = $_POST["enter_code"];
|
||||||
/*
|
/*
|
||||||
@@ -19,14 +20,29 @@ include "./../setup/connect_db.php";
|
|||||||
|
|
||||||
$return_array = array();
|
$return_array = array();
|
||||||
|
|
||||||
$query = "SELECT UserID FROM moty_user WHERE Name=? AND enterCode=?";
|
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('ss', $name, $enterCode);
|
$stmt->bind_param('s', $maestro_name);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($maestro_id);
|
||||||
|
// while($stmt->fetch()) {
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// $maestro_id = 1;
|
||||||
|
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND enterCode=?";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('iss', $maestro_id, $name, $enterCode);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($user_id);
|
$stmt->bind_result($user_id);
|
||||||
// while($stmt->fetch())
|
// while($stmt->fetch())
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
$db_conn->close();
|
||||||
|
|
||||||
|
$jsonUserData["MaestroID"] = $maestro_id;
|
||||||
$jsonUserData["UserID"] = $user_id;
|
$jsonUserData["UserID"] = $user_id;
|
||||||
echo json_encode($jsonUserData, JSON_UNESCAPED_UNICODE);
|
echo json_encode($jsonUserData, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user