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 @@
- {{ $t('not-emailed') }}
-
-
+
+ +