Fix: fail to login - not activated, over date
This commit is contained in:
@@ -11,6 +11,7 @@ function login() {
|
|||||||
(jsonData) => {
|
(jsonData) => {
|
||||||
maestroID = jsonData["maestroID"];
|
maestroID = jsonData["maestroID"];
|
||||||
sessionStorage.setItem("maestroID", maestroID);
|
sessionStorage.setItem("maestroID", maestroID);
|
||||||
|
|
||||||
location.href = './../maestro/main_menu.html';
|
location.href = './../maestro/main_menu.html';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -4,70 +4,93 @@ header("Content-Type: application/json");
|
|||||||
include "./../lib/send_reply_json.php";
|
include "./../lib/send_reply_json.php";
|
||||||
include "./../setup/connect_db.php";
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
$maestro_name = $_POST["maestro_name"];
|
$maestroName = $_POST["maestro_name"];
|
||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
/*
|
|
||||||
if(!is_numeric($enterCode)) {
|
|
||||||
send_error_code("생년월일이 숫자가 아닙니다. : ".$enterCode);
|
|
||||||
exit;
|
|
||||||
} else if(strlen($enterCode) != 6) {
|
|
||||||
send_error_code("6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : ".$enterCode);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$maestro_id = get_maestro_id($maestro_name);
|
|
||||||
if($maestro_id === null) {
|
$maestroID = get_maestro_id($maestroName);
|
||||||
|
if($maestroID === null) {
|
||||||
set_error_code("not_registered_id");
|
set_error_code("not_registered_id");
|
||||||
set_error_message("등록되지 않은 마에스트로 아이디입니다.");
|
set_error_message("등록되지 않은 마에스트로 아이디입니다.");
|
||||||
send_result_fail();
|
send_result_fail();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$login_data = login($maestro_name, $password);
|
$loginData = login($maestroName, $password);
|
||||||
if($login_data === null || $login_data[maestroID] === null) {
|
|
||||||
|
$date = new DateTime($loginData[availableActivateDateTime]);
|
||||||
|
$now = new DateTime();
|
||||||
|
if($loginData === null) {
|
||||||
|
set_error_code("no_data");
|
||||||
|
set_error_message("로그인하지 못했습니다.");
|
||||||
|
send_result_fail();
|
||||||
|
exit;
|
||||||
|
} else if($loginData[activateStatus] === 0) {
|
||||||
|
set_error_code("over_date");
|
||||||
|
set_error_message("마에스트로 계정이 아직 활성화되지 않았습니다.");
|
||||||
|
send_result_fail();
|
||||||
|
exit;
|
||||||
|
} else if($loginData[activateStatus] === 1 && $date < $now) {
|
||||||
|
set_error_code("over_date");
|
||||||
|
$date = new DateTime($loginData[availableActivateDateTime]);
|
||||||
|
set_error_message("마에스트로 계정의 유효기간이 지났습니다. : ".$date->format("Y-m-d H:i:s"));
|
||||||
|
send_result_fail();
|
||||||
|
exit;
|
||||||
|
} else if($loginData[maestroID] === null) {
|
||||||
set_error_code("wrong_password");
|
set_error_code("wrong_password");
|
||||||
set_error_message("비밀번호가 틀렸습니다.");
|
set_error_message("비밀번호가 틀렸습니다.");
|
||||||
send_result_fail();
|
send_result_fail();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_data("maestroID", $login_data[maestroID]);
|
set_data("maestroID", $loginData[maestroID]);
|
||||||
|
set_data("activateStatus", $loginData[activateStatus]);
|
||||||
|
set_data("availableActivateDateTime", $loginData[availableActivateDateTime]);
|
||||||
send_result_success();
|
send_result_success();
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function get_maestro_id($maestro_name) {
|
function get_maestro_id($maestroName) {
|
||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
|
$query = "
|
||||||
|
SELECT MaestroID
|
||||||
|
FROM moty_maestro
|
||||||
|
WHERE Name = ?
|
||||||
|
";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param("s", $maestro_name);
|
$stmt->bind_param("s", $maestroName);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($maestro_id);
|
$stmt->bind_result($maestroID);
|
||||||
// while($stmt->fetch()) {
|
// while($stmt->fetch()) {
|
||||||
// ;
|
// ;
|
||||||
// }
|
// }
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
return $maestro_id;
|
return $maestroID;
|
||||||
}
|
}
|
||||||
|
|
||||||
function login($maestro_name, $password) {
|
function login($maestroName, $password) {
|
||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=? AND Password=PASSWORD(?)";
|
$query = "
|
||||||
|
SELECT MaestroID, ActivateStatus, AvailableActivateDateTime
|
||||||
|
FROM moty_maestro
|
||||||
|
WHERE Name = ? AND Password = PASSWORD(?)
|
||||||
|
";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param("ss", $maestro_name, $password);
|
$stmt->bind_param("ss", $maestroName, $password);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($maestro_id);
|
$stmt->bind_result($maestroID, $activateStatus, $availableActivateDateTime);
|
||||||
// while($stmt->fetch())
|
// while($stmt->fetch())
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
$result["maestroID"] = $maestro_id;
|
$result["maestroID"] = $maestroID;
|
||||||
|
$result["activateStatus"] = $activateStatus;
|
||||||
|
$result["availableActivateDateTime"] = $availableActivateDateTime;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user