Add: MaestroID for login

This commit is contained in:
2018-05-27 22:16:57 +09:00
parent 4863a8d3f1
commit ef2218bfa6
3 changed files with 60 additions and 38 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ class DBConnectManager {
return "../";
}
requestCheckUserLogin(userName, enterCode, onSucceededListener, onFailedListener) {
requestCheckUserLogin(maestroName, userName, enterCode, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/user/login.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -61,7 +61,7 @@ class DBConnectManager {
onFailedListener(jsonData);
}
};
xhr.send("name=" + userName + "&enter_code=" + enterCode);
xhr.send("maestro_name=" + maestroName + "&name=" + userName + "&enter_code=" + enterCode);
}
requestPlayerHistory(date, listener) {
+40 -34
View File
@@ -8,7 +8,7 @@ class Login {
}
create() {
self = this;
this.textStyle = { font: "bold 32px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "middle" };
sessionStorageManager.clear();
@@ -21,53 +21,56 @@ class Login {
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();
}
makeInputTypeTexts() {
// name
let textX = this.game.world.centerX - 360;
let inputX = this.game.world.centerX + 60;
let nameTextY = 340;
game.add.text(textX, nameTextY, "이름 :", textStyleBasic)
makeMaestroNameText(x, y) {
this.makeTextField(x, y, "마에스트로 계정 :");
this.inputTextMaestroName = this.makeInputTypeText(x, y, "jisangs");
}
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)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.boundsAlignH = 'right';
}
this.inputTextName = new InputTypeText(inputX, nameTextY);
this.inputTextName.anchor.set(0.5);
this.inputTextName.canvasInput.value('');
makeInputTypeText(x, y, text) {
self = this;
let inputText = new InputTypeText(x + 420, y);
inputText.anchor.set(0.5);
inputText.canvasInput.value('');
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) {
self.startMenu();
}
}
// birthday
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();
return inputText;
}
makeButton() {
@@ -79,11 +82,13 @@ class Login {
}
startMenu() {
let maestroName = self.inputTextMaestroName.canvasInput._value;
sessionStorageManager.playerName = self.inputTextName.canvasInput._value;
let enterCode = self.inputTextEnterCode.canvasInput._value;
let dbConnectManager = new DBConnectManager();
dbConnectManager.requestCheckUserLogin(
maestroName,
sessionStorageManager.playerName,
enterCode,
self.loginSucceeded,
@@ -92,6 +97,7 @@ class Login {
}
loginSucceeded(jsonData) {
sessionStorageManager.maestroID = jsonData['MaestroID'];
sessionStorageManager.playerUserID = jsonData['UserID'];
sessionStorageManager.playingAppName = "menu";
+18 -2
View File
@@ -3,6 +3,7 @@ header('Content-Type: application/json');
include "./../send_error_code.php";
$maestro_name = $_POST["maestro_name"];
$name = $_POST["name"];
$enterCode = $_POST["enter_code"];
/*
@@ -19,14 +20,29 @@ include "./../setup/connect_db.php";
$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->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->bind_result($user_id);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
$db_conn->close();
$jsonUserData["MaestroID"] = $maestro_id;
$jsonUserData["UserID"] = $user_id;
echo json_encode($jsonUserData, JSON_UNESCAPED_UNICODE);