Add: update maestro info, password php
This commit is contained in:
@@ -51,8 +51,7 @@ function checkMaestroID() {
|
|||||||
let message = maestroName + " : 새로 등록할 수 있는 마에스트로 아이디입니다.";
|
let message = maestroName + " : 새로 등록할 수 있는 마에스트로 아이디입니다.";
|
||||||
showErrorMessage(message, "success");
|
showErrorMessage(message, "success");
|
||||||
|
|
||||||
$("#id_ckeck_help").text("");
|
// $("#password").focus();
|
||||||
$("#password").focus();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
(errorMessage, errorCode) => {
|
(errorMessage, errorCode) => {
|
||||||
@@ -83,7 +82,7 @@ function checkData() {
|
|||||||
showErrorMessage("아이디를 입력해 주세요.", "error");
|
showErrorMessage("아이디를 입력해 주세요.", "error");
|
||||||
$("#maestro_name").focus();
|
$("#maestro_name").focus();
|
||||||
return;
|
return;
|
||||||
}else if(!isAvailableID) {
|
} else if(!isAvailableID) {
|
||||||
onErrorMaestroID("아이디 중복 확인을 해 주세요.", "error");
|
onErrorMaestroID("아이디 중복 확인을 해 주세요.", "error");
|
||||||
$("#check_id").focus();
|
$("#check_id").focus();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,7 +1,193 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
let isChangedIDName = false;
|
||||||
|
let isAvailableIDName = false;
|
||||||
|
let registeredMaestroIDName = "";
|
||||||
|
let registeredEmail = "";
|
||||||
|
let registeredPassword = "";
|
||||||
|
|
||||||
|
|
||||||
|
let newMaestroIDName = "";
|
||||||
|
let newEmail = "";
|
||||||
|
|
||||||
|
let newPassword = "";
|
||||||
|
let newPasswordVerify = "";
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
loadMaestroInfo(maestroID);
|
||||||
|
|
||||||
|
$('#maestro_id').bind('input propertychange', function() {
|
||||||
|
onChangeMaestroIDName();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadMaestroInfo(maestroID) {
|
||||||
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
|
"./../server/maestro/maestro_info.php",
|
||||||
|
"maestro_id=" + maestroID,
|
||||||
|
|
||||||
|
(jsonData) => {
|
||||||
|
console.log(jsonData);
|
||||||
|
registeredMaestroIDName = jsonData.name;
|
||||||
|
$("#maestro_id").val(registeredMaestroIDName);
|
||||||
|
|
||||||
|
registeredEmail = jsonData.email;
|
||||||
|
$("#email").val(registeredEmail);
|
||||||
|
},
|
||||||
|
|
||||||
|
(errorMessage, errorCode) => {
|
||||||
|
showErrorMessage(errorMessage, "error");
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChangeMaestroIDName() {
|
||||||
|
isChangedIDName = true;
|
||||||
|
isAvailableIDName = false;
|
||||||
|
$("#id_ckeck").prop("disabled", false)
|
||||||
|
$("#id_ckeck_help").removeClass("d-none");
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkMaestroIDName() {
|
||||||
|
newMaestroIDName = $("#maestro_id").val();
|
||||||
|
|
||||||
|
if(!accountValidator.isValidMaestroID(newMaestroIDName)) {
|
||||||
|
showErrorMessage(accountValidator.messageForInvalidMaestroID(newMaestroIDName), "error");
|
||||||
|
$("#maestro_id").focus();
|
||||||
|
$("#maestro_id").select();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
|
"./../server/maestro/check_id.php",
|
||||||
|
"maestro_name=" + newMaestroIDName,
|
||||||
|
|
||||||
|
(jsonData) => {
|
||||||
|
isAvailableIDName = true;
|
||||||
|
isChangedIDName = false;
|
||||||
|
showErrorMessage(newMaestroIDName + " : 새로 등록할 수 있는 마에스트로 아이디입니다.", "success");
|
||||||
|
|
||||||
|
$("#id_ckeck").prop("disabled", true)
|
||||||
|
$("#id_ckeck_help").addClass("d-none");
|
||||||
|
},
|
||||||
|
|
||||||
|
(errorMessage, errorCode) => {
|
||||||
|
isAvailableIDName = false;
|
||||||
|
showErrorMessage(errorMessage, "error");
|
||||||
|
// $("#maestro_name").val("");
|
||||||
|
$("#maestro_id").focus();
|
||||||
|
$("#maestro_id").select();
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function changeMaestroInfo() {
|
function changeMaestroInfo() {
|
||||||
location.href="main_menu.html";
|
newMaestroIDName = $("#maestro_id").val();
|
||||||
|
if(newMaestroIDName.length === 0) {
|
||||||
|
showErrorMessage("변경할 아이디를 입력해 주세요.", "error");
|
||||||
|
$("#maestro_id").focus();
|
||||||
|
return;
|
||||||
|
} else if(isChangedIDName && !isAvailableIDName) {
|
||||||
|
showErrorMessage("아이디 중복 확인을 해 주세요.", "error");
|
||||||
|
$("#id_ckeck").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
newEmail = $("#email").val();
|
||||||
|
if(newEmail.length === 0) {
|
||||||
|
showErrorMessage("이메일을 입력해 주세요.", "error");
|
||||||
|
$("#email").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(registeredMaestroIDName === newMaestroIDName && registeredEmail === newEmail) {
|
||||||
|
showErrorMessage("변경된 정보가 없습니다.", "error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
|
"./../server/maestro/update_maestro_info.php",
|
||||||
|
"maestro_id=" + maestroID + "&maestro_name=" + newMaestroIDName + "&email=" + newEmail,
|
||||||
|
|
||||||
|
(jsonData) => {
|
||||||
|
alert(
|
||||||
|
"마에스트로 계정 정보가 변경되었습니다.\n"
|
||||||
|
+ "아이디 : " + newMaestroIDName + "\n"
|
||||||
|
+ "이메일 : " + newEmail
|
||||||
|
);
|
||||||
|
location.href="main_menu.html";
|
||||||
|
},
|
||||||
|
|
||||||
|
(errorMessage, errorCode) => {
|
||||||
|
isAvailableIDName = false;
|
||||||
|
showErrorMessage(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPassword() {
|
||||||
|
registeredPassword = $("#prev_password").val();
|
||||||
|
if(registeredPassword.length === 0) {
|
||||||
|
showErrorMessage("현재 암호를 입력해 주세요.", "error");
|
||||||
|
$("#prev_password").focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
newPassword = $("#new_password").val();
|
||||||
|
if(newPassword.length === 0) {
|
||||||
|
showErrorMessage("새로운 암호를 입력해 주세요.", "error");
|
||||||
|
$("#new_password").focus();
|
||||||
|
return;
|
||||||
|
} else if(!accountValidator.isValidMaestroPW(newPassword)) {
|
||||||
|
showErrorMessage(accountValidator.messageForInvalidMaestroPW(newPassword), "error");
|
||||||
|
$("#new_password").focus();
|
||||||
|
$("#new_password").select();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
newPasswordVerify = $("#new_password_verify").val();
|
||||||
|
if(newPassword !== newPasswordVerify) {
|
||||||
|
showErrorMessage(
|
||||||
|
"[새로운 암호]와 [새로운 암호 확인]의 내용이 일치하지 않습니다.<br/>둘 다 같은 내용으로 다시 한 번 입력해 주세요.",
|
||||||
|
"error"
|
||||||
|
);
|
||||||
|
$("#new_password_verify").focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(registeredPassword === newPassword) {
|
||||||
|
showErrorMessage("[새로운 암호]가 현재 암호와 동일합니다.", "error");
|
||||||
|
$("#new_password").focus();
|
||||||
|
$("#new_password").select();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeMaestroPassword() {
|
||||||
|
if(!checkPassword())
|
||||||
|
return;
|
||||||
|
|
||||||
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
|
"./../server/maestro/update_maestro_password.php",
|
||||||
|
"maestro_id=" + maestroID + "®istered_pw=" + registeredPassword + "&new_pw=" + newPassword,
|
||||||
|
|
||||||
|
(jsonData) => {
|
||||||
|
alert("패스워드가 변경되었습니다.");
|
||||||
|
location.href="main_menu.html";
|
||||||
|
},
|
||||||
|
|
||||||
|
(errorMessage, errorCode) => {
|
||||||
|
showErrorMessage(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -10,42 +196,85 @@ function changeMaestroInfo() {
|
|||||||
|
|
||||||
<div class="container my-3">
|
<div class="container my-3">
|
||||||
|
|
||||||
|
<div id="message_box">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card border-primary">
|
<div class="card border-primary">
|
||||||
<div class="card-header bg-light"><span class="h4">마에스트로 계정 정보 수정</span></div>
|
<div class="card-header bg-light"><span class="h4">마에스트로 계정 정보 수정</span></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<form class="mx-4">
|
<form class="mx-4">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="maestro_name" class="col-sm-2 col-form-label">* 아이디 변경</label>
|
<label for="maestro_id" class="col-sm-2 col-form-label text-primary">* 변경할 아이디</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" id="maestro_name" placeholder="아이디 입력">
|
<input type="text" class="form-control" id="maestro_id" placeholder="아이디 입력">
|
||||||
<small class="form-text text-muted">4~20 글자. 영문, 숫자만 사용 가능합니다.</small>
|
<small class="form-text text-muted">4~20 글자. 영문, 숫자만 사용 가능합니다.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="button" id="id_ckeck" class="btn btn-info" value="중복 체크" onClick="checkMaestroID()" disabled>
|
<input type="button" id="id_ckeck" class="btn btn-warning" value="중복 체크" onClick="checkMaestroIDName()" disabled>
|
||||||
|
<small id="id_ckeck_help" class="form-text text-danger d-none">[중복 체크] 버튼을 눌러주세요.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="password" class="col-sm-2 col-form-label">* 암호</label>
|
<label for="email" class="col-sm-2 col-form-label text-primary">* 변경할 이메일</label>
|
||||||
<div class="col-sm-6">
|
|
||||||
<input type="password" class="form-control" id="password" placeholder="Password">
|
|
||||||
<small class="form-text text-muted">4~16 글자. 영문, 숫자만 사용 가능합니다.</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group row">
|
|
||||||
<label for="email" class="col-sm-2 col-form-label">* 이메일</label>
|
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="email" class="form-control" id="email" placeholder="name@example.com">
|
<input type="email" class="form-control" id="email" placeholder="name@example.com">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-5 mb-1 text-danger">위 내용으로 마에스트로 계정 정보를 변경합니다.</div>
|
<div class="mt-5 mb-1 text-danger">위 내용으로 마에스트로 계정 정보를 변경합니다.</div>
|
||||||
<button type="button" class="btn btn-danger btn-block btn-lg" onClick="changeMaestroInfo()">변경</button>
|
<button type="button" class="btn btn-primary btn-block btn-lg" onClick="changeMaestroInfo()">변경</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div> <!-- card body -->
|
</div> <!-- card body -->
|
||||||
|
|
||||||
</div>
|
</div> <!-- change maestro info -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="card border-primary my-3">
|
||||||
|
<div class="card-header bg-light"><span class="h4">마에스트로 암호 변경</span></div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<div id="message_box">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form class="mx-4">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="prev_password" class="col-sm-2 col-form-label">* 현재 암호</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="password" class="form-control" id="prev_password" placeholder="Password">
|
||||||
|
<small class="form-text text-muted">기존에 사용하던 암호를 입력하세요.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<hr class="mx-3 mb-4"/>
|
||||||
|
|
||||||
|
<form class="mx-4">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="new_password" class="col-sm-2 col-form-label text-primary">* 새로운 암호</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="password" class="form-control" id="new_password" placeholder="Password">
|
||||||
|
<small class="form-text text-muted">4~16 글자. 영문, 숫자만 사용 가능합니다.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="new_password_verify" class="col-sm-2 col-form-label text-primary">* 새로운 암호 확인</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="password" class="form-control" id="new_password_verify" placeholder="Password">
|
||||||
|
<small class="form-text text-muted">위에 입력한 암호를 다시 한 번 정확히 입력하세요.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 mb-1 text-danger">위 내용으로 마에스트로 암호를 변경합니다.</div>
|
||||||
|
<button type="button" class="btn btn-primary btn-block btn-lg" onClick="changeMaestroPassword()">변경</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div> <!-- card body -->
|
||||||
|
|
||||||
|
</div> <!-- change password -->
|
||||||
|
|
||||||
</div> <!-- container -->
|
</div> <!-- container -->
|
||||||
@@ -15,6 +15,7 @@ if($info === null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_data("name", $info["name"]);
|
set_data("name", $info["name"]);
|
||||||
|
set_data("email", $info["email"]);
|
||||||
set_data("accountType", $info["accountType"]);
|
set_data("accountType", $info["accountType"]);
|
||||||
set_data("playerCount", $info["playerCount"]);
|
set_data("playerCount", $info["playerCount"]);
|
||||||
send_result_success();
|
send_result_success();
|
||||||
@@ -25,19 +26,20 @@ function get_maestro_info($maestroID) {
|
|||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT Name, AccountType, PlayerCount
|
SELECT Name, Email, AccountType, PlayerCount
|
||||||
FROM moty_maestro
|
FROM moty_maestro
|
||||||
WHERE MaestroID = ?
|
WHERE MaestroID = ?
|
||||||
";
|
";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param("s", $maestroID);
|
$stmt->bind_param("s", $maestroID);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($name, $accountType, $playerCount);
|
$stmt->bind_result($name, $email, $accountType, $playerCount);
|
||||||
// while($stmt->fetch())
|
// while($stmt->fetch())
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
$info["name"] = $name;
|
$info["name"] = $name;
|
||||||
|
$info["email"] = $email;
|
||||||
$info["accountType"] = $accountType;
|
$info["accountType"] = $accountType;
|
||||||
$info["playerCount"] = $playerCount;
|
$info["playerCount"] = $playerCount;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
$maestroID = $_POST["maestro_id"];
|
||||||
|
$maestroName = $_POST["maestro_name"];
|
||||||
|
$email = $_POST["email"];
|
||||||
|
|
||||||
|
|
||||||
|
update_maestro_info($maestroID, $maestroName, $email);
|
||||||
|
|
||||||
|
send_result_success();
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
function update_maestro_info($maestroID, $maestroName, $email) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
UPDATE moty_maestro
|
||||||
|
SET Name = ?, Email = ?
|
||||||
|
WHERE MaestroID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("ssi", $maestroName, $email, $maestroID);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
$maestroID = $_POST["maestro_id"];
|
||||||
|
$registeredPW = $_POST["registered_pw"];
|
||||||
|
$newPW = $_POST["new_pw"];
|
||||||
|
|
||||||
|
|
||||||
|
$countResult = maestro_registered_password($maestroID, $registeredPW);
|
||||||
|
if($countResult === null || $countResult < 1) {
|
||||||
|
set_error_message("입력하신 [현재 암호]가 맞지 않습니다.");
|
||||||
|
send_result_fail();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_maestro_password($maestroID, $newPW);
|
||||||
|
|
||||||
|
send_result_success();
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
function maestro_registered_password($maestro_id, $registeredPW) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT COUNT(MaestroID)
|
||||||
|
FROM moty_maestro
|
||||||
|
WHERE MaestroID = ? AND Password = PASSWORD(?)
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("is", $maestro_id, $registeredPW);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($countResult);
|
||||||
|
// while($stmt->fetch())
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $countResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_maestro_password($maestroID, $newPW) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
UPDATE moty_maestro
|
||||||
|
SET Password = PASSWORD(?)
|
||||||
|
WHERE MaestroID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("si", $newPW, $maestroID);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user