const passLevel1 = async() => {
setLevel1(false);
setLevel2(false);
setValidateMsg("empty");
setConfirmMsg("empty");
//----FORMAT CHECK----//
if(!phoneNum) {
setValidateMsg("needPhoneNum");
return false;
}
if(phoneNum.length < 12) {
setValidateMsg("informal");
return false;
}
//----DUPLICATE CHECK----//
try {
const params = {
srch : 'cellphone',
kwd : phoneNum
}
const result = await apiCall.get("/join/any/makeDigit", {params});
setValidateMsg("sentCertNum");
setCdata(result.data.c);
setSetTime(result.data.exp);
setMemberId(result.data.memberId);
}catch(e){
console.log(e);
return false;
}
//----LEVEL1 PASSED----//
setLevel1(true);
//navigate('/Login/Phone?extraHide', { replace : true }); // for input scan
setExpired(false);
};
const passLevel2 = async() => {
setLevel2(false);
setConfirmMsg("empty");
//----CERTIFICATE----//
try {
const params = {
data : certNum
}
const result = await apiCall.get(`/join/${cData}/digitChk`, {params});
if(result.data['res'] == "MISMATCH") return setConfirmMsg("differCertNum");
if(result.data['res'] == "EXPIRED") return setConfirmMsg("timeExpired");
if(result.data['res'] == "MATCH"){
if(memberId){ //----CASE MEMBER ALREADY----//
const loginResult = await apiCall.get(`/login/${memberId}/phone`);
if(loginResult.data.res == "SUCCESS"){
window.localStorage.setItem('token', JSON.stringify(loginResult.data.token));
if(order && order.set){
const selfResult = await apiCall.get(`/self/self`);
setSelfHandler(selfResult.data); //----SELF CONTEXT SET----//
navigate('/Order', {replace : true });
return false;
}
navigate('/', { replace : true });
}else{
setAlertMsg("loginProblem");
setAlert(true);
return false;
}
}
setConfirmMsg("passedCert"); //----CASE NEW MEMBER----//
setCertPhone(result.data['kwdData']);
setLevel2(true);
}
}catch(e){
console.log(e);
return false;
}
};
function phone(){
$result = array();
try{
$id = $this->param['ident'];
$row = $this->member->get($id,"mb_id,mb_stt,pt_id,mb_passwd,mb_login_cnt,count(mb_id) as cnt");
$value = array();
if(count($row)){
$value['mb_last_login_dt'] = _DATE_YMDHIS;
$value['mb_last_login_ip'] = $_SERVER['REMOTE_ADDR'];
$value['mb_login_cnt'] = $row['mb_login_cnt']+1;
$res = $this->member->set($value,$row['mb_id'],"value");
$result['token'] = array(
'access' => $this->jwt->hashing(array("index" => $id, "exp" => time()+($this->expiration))),
'refresh' => $this->jwt->hashing(array("index" => $id, "exp" => time()+2*($this->expiration)))
);
$result['res'] = "SUCCESS";
};
}catch(Exception $e){
$result['res'] = "FAILED";
}
echo json_encode($result);
}