diff --git a/src/Controller/Basic/AboutController.php b/src/Controller/Basic/AboutController.php index 0e5ad6e..9ccfddc 100644 --- a/src/Controller/Basic/AboutController.php +++ b/src/Controller/Basic/AboutController.php @@ -17,24 +17,4 @@ class AboutController extends AbstractController { - /** - * @Route("/about/devs", name="about") - */ - public function index() - { - $repo = $this->getDoctrine()->getManager()->getRepository(Preference::class); - return $this->response()->response($repo->get(Preference::ABOUT_DEVS)); - } - - /** - * @Route("/about/version") - */ - public function version() - { - exec('git lg2 -10', $gitHashLong); - $gitHashLong = array_reduce($gitHashLong, function ($previous, $current) { - return $previous . "
" . $current; - }); - return $this->response()->response($gitHashLong); - } } diff --git a/src/Controller/School/AlumniController.php b/src/Controller/School/AlumniController.php index e1301bc..22a8a77 100644 --- a/src/Controller/School/AlumniController.php +++ b/src/Controller/School/AlumniController.php @@ -181,7 +181,7 @@ public function saveForm(Request $request) /** * @Route("alumni/submit", methods="POST") */ - public function submitForm(Request $request, ValidatorInterface $validator, TranslatorInterface $translator) + public function submitForm(Request $request, ValidatorInterface $validator, TranslatorInterface $translator, NotificationService $service) { $this->denyAccessUnlessGranted(Permission::IS_LOGIN); if (!$this->verfityCsrfToken($request->request->get("_csrf"), AbstractController::CSRF_ALUMNI_FORM)) @@ -229,7 +229,7 @@ public function submitForm(Request $request, ValidatorInterface $validator, Tran $form->setStatus(1); $form->setSubmitTime(new \DateTime()); - //$this->notification()->notifyNewVerification($form); + $service->newVerification($form); $em->persist($form); $em->flush(); return $this->response()->responseEntity(null, 200); diff --git a/src/Controller/School/VoteController.php b/src/Controller/School/VoteController.php index db0c752..9f94489 100644 --- a/src/Controller/School/VoteController.php +++ b/src/Controller/School/VoteController.php @@ -65,9 +65,9 @@ public function vote(Request $request, TranslatorInterface $translator) { return $this->response()->response($translator->trans("already-submit"), Response::HTTP_FORBIDDEN); try { $ticket = new Ticket($vote, $this->getUser(), $request->request->get("choices")); - $em->persist($ticket); $em->flush(); + $this->writeLog("UserVoted", $request->request->get("choices"), $this->getUser()); return $this->response()->responseEntity($ticket, Response::HTTP_OK); } catch(\Exception $e) { return $this->response()->response($translator->trans("invalid-ticket"), Response::HTTP_BAD_REQUEST); diff --git a/src/Controller/User/OAuthController.php b/src/Controller/User/OAuthController.php index ab720f0..a0ee0dd 100644 --- a/src/Controller/User/OAuthController.php +++ b/src/Controller/User/OAuthController.php @@ -43,7 +43,13 @@ public function authorize(Request $request) return new RedirectResponse("/#/user/login?redirect=" . urlencode($request->getUri())); } if (is_null($user->getEmail())) { - return new RedirectResponse("/#/user/security?reason=email"); + return new RedirectResponse("/#/user/security?reason=incomplete"); + } + if (is_null($user->getPhone()) && geoip_country_code_by_name($request->getClientIp()) === "CN") { + return new RedirectResponse("/#/user/security?reason=incomplete"); + } + if (geoip_country_code_by_name($request->getClientIp()) !== "CN" && is_null($this->getUser()->getValidAuth())) { + return new RedirectResponse("/#/user/security?reason=incomplete"); } try { $authRequest = $this->server->validateAuthorizationRequest($psrRequest); diff --git a/src/Controller/User/UserController.php b/src/Controller/User/UserController.php index 8c0e401..382ee36 100644 --- a/src/Controller/User/UserController.php +++ b/src/Controller/User/UserController.php @@ -87,7 +87,7 @@ public function login(Request $request, UserPasswordEncoderInterface $passwordEn return $this->response()->response($translator->trans("banned"), Response::HTTP_UNAUTHORIZED); if ($passwordEncoder->isPasswordValid($user, $request->request->get("password", $user->getSalt()))) { $session->set("user_token", $user->getToken()); - + $this->writeLog("UserLoginSucceeded", null, $user); if ($request->request->get("remember") == "true") { $response = $this->response()->response(null); $time = new \DateTime(); @@ -95,7 +95,6 @@ public function login(Request $request, UserPasswordEncoderInterface $passwordEn $response->headers->setCookie(new Cookie("remember_token", $user->getToken(), $time, "/", null, false, true)); return $response; } - $this->writeLog("UserLoginSucceeded", null, $user); return $this->response()->response(null); } else { $this->writeLog("UserLoginFailed", null, $user); diff --git a/src/Service/NotificationService.php b/src/Service/NotificationService.php index ca57e09..b129533 100644 --- a/src/Service/NotificationService.php +++ b/src/Service/NotificationService.php @@ -19,6 +19,7 @@ use App\Type\CodeActionType; use App\Type\DeviceType; use Doctrine\Common\Persistence\ObjectManager; +use Longman\TelegramBot\Telegram; class NotificationService { @@ -302,6 +303,22 @@ public function blackboardDeadline(User $teacher, array $students, string $title ); } + /** + * @deprecated + */ + public function newVerification(Alumni $ticket){ + $info = "【实名认证】新的实名认证请求,来自 " . $ticket->getChineseName(). "(".$ticket->getUser()->getUsername().")"; + $this->sendTelegram($info); + } + + public function sendTelegram(string $text) { + try { + $telegram = new Telegram($_ENV["TELEGRAM_BOT_KEY"]); + $result = \Longman\TelegramBot\Request::sendMessage(['chat_id'=>-1001244396269, 'text'=>$text]); + } catch (\Exception $e) { + } + } + private function getDevices(User $user) { return $this->objectManager->getRepository(Device::class)->findValidByUserAndType($user, DeviceType::IOS, true); } diff --git a/templates/index.html.twig b/templates/index.html.twig index c084422..3ae6226 100644 --- a/templates/index.html.twig +++ b/templates/index.html.twig @@ -13,7 +13,6 @@ NFLS.IO 南外人 \ No newline at end of file diff --git a/web/components/Components/App.vue b/web/components/Components/App.vue index 9eae5f6..2822135 100644 --- a/web/components/Components/App.vue +++ b/web/components/Components/App.vue @@ -32,9 +32,6 @@ {{unread}} - - help_outline - {{ $t('support') }} delete {{ $t('drop-admin') }} @@ -90,10 +87,10 @@ {{ $t('general') }} - + forum {{ $t('forum') }} - + library_books {{ $t('wiki') }} @@ -115,7 +112,7 @@ plus_one {{ $t('vote') }} - + pool {{ $t('study') }} @@ -132,9 +129,6 @@ {{ $t('other') }} - - adb - {{ $t('about') }} developer_mode {{ $t('development') }} @@ -146,7 +140,7 @@ {{ $t('admin') }} - + build {{ $t('console') }} diff --git a/web/components/User/Security.vue b/web/components/User/Security.vue index 9b7701b..e8446f4 100644 --- a/web/components/User/Security.vue +++ b/web/components/User/Security.vue @@ -1,89 +1,93 @@ @@ -96,8 +100,8 @@ task: "", email: "", phone: "", - oauth: false, - form: {} + form: {}, + incomplete: false }), created: function () { this.resetForm() @@ -105,8 +109,7 @@ mounted: function () { this.$emit("changeTitle", this.$t("security-title")) this.$emit("prepareRecaptcha") - if (this.$route.query.reason === "email") - this.oauth = true + this.incomplete = (this.$route.query.reason === 'incomplete') }, methods: { resetForm() { diff --git a/web/router/index.js b/web/router/index.js index 14da5c3..156366a 100644 --- a/web/router/index.js +++ b/web/router/index.js @@ -4,8 +4,6 @@ import Jump from '../components/Jump' import App from '../components/Components/App' import Dashboard from '../components/Dashboard' -import About from '../components/About/About' - import Directory from '../components/Alumni/Directory' import Realname from '../components/Alumni/Realname' import Form from '../components/Alumni/Form' @@ -44,9 +42,6 @@ export default new Router({ { path: '/dashboard', component: Dashboard - }, { - path: '/about', - component: About }, { path: '/alumni/auth', component: Realname