diff --git a/api/checkAccount.php b/api/checkAccount.php new file mode 100644 index 0000000..84786ac --- /dev/null +++ b/api/checkAccount.php @@ -0,0 +1,34 @@ +connect('redis',6379); + + +$hash = $_REQUEST['hash']; + +if(!isset($hash)) die(); + + + +if($redis->exists('account/'.$hash)){ + + + $arr = json_decode($redis->get('account/'.$hash)); + + if(!$arr['isExist']){ + $arr_t = $arr; + unset($arr_t['isExist']); + $cnn = db__connect(); + db__pushData($cnn, "account", $arr_t); + $arr['isExist'] = true; + $redis->set('account/'.$arr['hash'], json_encode($arr)); + } + + + echo json_encode(array("code"=> 200, "hash"=>$arr['hash'], "message" => "Verified successfully!")); + +}else{ + echo json_encode(array("code"=> 500, "message"=>"Error!!")); +} diff --git a/api/emailCode.php b/api/emailCode.php index 731f259..ec05f6b 100644 --- a/api/emailCode.php +++ b/api/emailCode.php @@ -25,3 +25,6 @@ curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); +echo json_encode(array( + "code": 200 +)); \ No newline at end of file diff --git a/api/smsCode.php b/api/smsCode.php index 91a3958..318e490 100644 --- a/api/smsCode.php +++ b/api/smsCode.php @@ -26,3 +26,6 @@ curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); +echo json_encode(array( + "code": 200 +)); \ No newline at end of file diff --git a/api/verCode.php b/api/verCode.php index d369472..43dd2c0 100644 --- a/api/verCode.php +++ b/api/verCode.php @@ -1,20 +1,57 @@ connect('redis',6379); $usr = $_REQUEST['usr']; $code = $_REQUEST['code']; +$type = $_REQUEST['type']; if(!isset($usr)) die(); if(!isset($code)) die(); +if(!isset($type) || $type != 'tel' || $type != 'email') die(); if($redis->exists('vercode/'.$usr) && $redis->get('vercode/'.$usr) == $code){ - echo json_encode(array("code"=> 200, "message" => "Verified successfully!")); + $cnn = db__connect(); + + if($type == 'tel'){ + $res = db__getData($cnn, "account", "tel", $usr); + }else{ + $res = db__getData($cnn, "account", "email", $usr); + } + + if(count($res)){ + $arr = $res[0]; + $arr = array_merge($arr, array("isExist"=>true)); + }else{ + + $arr = array( + "nickname"=>null, + "avatar"=>null, + "tel"=>null, + "email"=>null, + "hash"=> hash('sha256', $usr.$code.$type.time()), + "group"=>"client", + "comments"=>"From ushio-login", + "created_at"=>date("Y-m-d H:i:s", time()), + "updated_at"=>date("Y-m-d H:i:s", time()) + + ); + if($type == 'tel'){ + $arr['tel'] = $usr; + }else{ + $arr['email'] = $usr; + } + $arr = array_merge($arr, array("isExist"=>false)); + } + $redis->set('account/'.$arr['hash'], json_encode($arr)); + echo json_encode(array("code"=> 200, "hash"=>$arr['hash'], "isExist"=>$arr['isExist'], "message" => "Verified successfully!")); }else{ echo json_encode(array("code"=> 500, "message"=>"Error!!")); diff --git a/index.html b/index.html index a027f1a..02c8d63 100644 --- a/index.html +++ b/index.html @@ -40,8 +40,9 @@

- + + 账号或密码错误,请重新输入

@@ -51,20 +52,6 @@ 120s 验证码错误

-
-
-

- - - 账号或密码错误 -

-

- - - 发送验证码 - 120s - 验证码错误 -

@@ -77,7 +64,7 @@ 忘记密码
--> - +