diff --git a/plugins/Common.php b/plugins/Common.php index f7d88b3..44643de 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -53,17 +53,22 @@ Class Common { return true; } - //判断用户数据目录是否存在 - public static function getUserDataDir($cellphone) { - $rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; - + //根据手机号码获取映射的用户名 + public static function getMappedUsername($cellphone){ $username = $cellphone; - - //账号映射,手机号码转换成4位数字的短账号 + if (!empty(FSC::$app['config']['tajia_user_map']) && !empty(FSC::$app['config']['tajia_user_map'][$username])) { $username = FSC::$app['config']['tajia_user_map'][$username]; } + return $username; + } + + //判断用户数据目录是否存在 + public static function getUserDataDir($cellphone) { + $rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; + + $username = self::getMappedUsername($cellphone); $userDir = "{$rootDir}{$username}"; return is_dir($userDir) ? $userDir : false; } @@ -90,17 +95,12 @@ Class Common { } $login_time = time(); - $username = $cellphone; + $username = self::getMappedUsername($cellphone); if (empty($friends_code) && !empty($_COOKIE['friends_code'])) { $friends_code = $_COOKIE['friends_code']; } - //账号映射,手机号码转换成4位数字的短账号 - if (!empty(FSC::$app['config']['tajia_user_map']) && !empty(FSC::$app['config']['tajia_user_map'][$username])) { - $username = FSC::$app['config']['tajia_user_map'][$username]; - } - $_SESSION['login_time'] = $login_time; $_SESSION['username'] = $username; $_SESSION['friends_code'] = $friends_code; diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index bb3579b..9d4f2f6 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -485,6 +485,15 @@ eof; if (empty($cellphone) || Common::isCellphoneNumber($cellphone) == false) { $err = "手机号码格式错误,请填写正确的手机号码"; }else { + //判断是否已经注册 + $userDataDir = Common::getUserDataDir($cellphone); + if (!empty($userDataDir) && $action == 'register') { + $err = '你已经注册,请直接登录'; + return $this->renderJson(compact('code', 'msg', 'err')); + } + + + //尝试发送短信验证码 $params = array( 'phoneNumber' => $cellphone, 'codeNumber' => $this->generateRandSmsCode(), @@ -565,14 +574,15 @@ eof; Common::saveFriendsCode($cellphone); Common::initUserData($cellphone, $friends_code); - $shareUrl = "/{$cellphone}/"; + $shareUrl = "/{$newUser['username']}/"; $msg = "注册完成,开始收藏你喜欢的视频吧,正在为你跳转到专属网址..."; $code = 1; }else { $err = '注册失败,请稍后再试'; } }else { - $shareUrl = "/{$cellphone}/"; + $username = Common::getMappedUsername($cellphone); + $shareUrl = "/{$username}/"; $msg = "已注册,正在为你跳转到专属网址..."; $code = 1; }