Example #1
0
    }
} else {
    Utils::raise('1', '空用户名。');
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
$json = null;
/**
 * Handle requests from index.php
 */
if ($action == "login") {
    if (checkPost()) {
        if (!$user->is_registered) {
            $json['errno'] = 1;
            $json['msg'] = "用户不存在哦";
        } else {
            if ($user->checkPasswd($_POST['passwd'])) {
                $json['errno'] = 0;
                $json['msg'] = '登录成功,欢迎回来~';
                $json['token'] = $user->getToken();
                $_SESSION['token'] = $user->getToken();
            } else {
                $json['errno'] = 1;
                $json['msg'] = "用户名或密码不对哦";
            }
        }
    }
} else {
    if ($action == "register") {
        if (checkPost('register')) {
            if (!$user->is_registered) {
                if (user::checkValidPwd($_POST['passwd'])) {