Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
UI: update
Browse files Browse the repository at this point in the history
  • Loading branch information
hqy2000 committed Aug 4, 2018
1 parent 9cab413 commit 382e79b
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 258 deletions.
20 changes: 0 additions & 20 deletions src/Controller/Basic/AboutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . "<br/>" . $current;
});
return $this->response()->response($gitHashLong);
}
}
4 changes: 2 additions & 2 deletions src/Controller/School/AlumniController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/School/VoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/Controller/User/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,14 @@ 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();
$time->add(new \DateInterval("P1M"));
$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);
Expand Down
17 changes: 17 additions & 0 deletions src/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Type\CodeActionType;
use App\Type\DeviceType;
use Doctrine\Common\Persistence\ObjectManager;
use Longman\TelegramBot\Telegram;

class NotificationService
{
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion templates/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<link rel="stylesheet" href="{{ asset('vue/vue.css') }}">
<title>NFLS.IO 南外人</title>
<style>
@import url(//fonts.googleapis.com/earlyaccess/notosansjapanese.css);
@import url(//fonts.googleapis.com/earlyaccess/notosanssc.css);
html, body, #app {
height: calc(100% - 20px);
Expand Down
2 changes: 1 addition & 1 deletion web/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<style>
#app {
font-family: 'Noto Sans Japanese', 'Noto Sans SC', 'Roboto', 'Avenir', Helvetica, Arial, sans-serif;
font-family: 'Noto Sans SC', 'Roboto', 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
Expand Down
131 changes: 0 additions & 131 deletions web/components/About/About.vue

This file was deleted.

14 changes: 4 additions & 10 deletions web/components/Components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
<md-chip class="md-accent" v-if="unread > 0">{{unread}}</md-chip>
</md-list-item>
<md-divider></md-divider>
<md-list-item href="https://dev.nfls.io/jira/openid/login/2">
<md-icon>help_outline</md-icon>
<span class='md-list-item-text'>{{ $t('support') }}</span></md-list-item>
<md-list-item v-if="admin" @click="dropAdmin">
<md-icon>delete</md-icon>
<span class='md-list-item-text'>{{ $t('drop-admin') }}</span></md-list-item>
Expand Down Expand Up @@ -90,10 +87,10 @@

<md-subheader>{{ $t('general') }}</md-subheader>

<md-list-item href='https://nfls.io/forum'>
<md-list-item href='https://forum.nfls.io'>
<md-icon>forum</md-icon>
<span class='md-list-item-text'>{{ $t('forum') }}</span></md-list-item>
<md-list-item href='https://nfls.io/wiki'>
<md-list-item href='https://wiki.nfls.io'>
<md-icon>library_books</md-icon>
<span class='md-list-item-text'>{{ $t('wiki') }}</span></md-list-item>

Expand All @@ -115,7 +112,7 @@
<md-list-item to='/school/vote'>
<md-icon>plus_one</md-icon>
<span class='md-list-item-text'>{{ $t('vote') }}</span></md-list-item>
<md-list-item disabled>
<md-list-item href='https://water.nfls.io'>
<md-icon>pool</md-icon>
<span class='md-list-item-text'>{{ $t('study') }}</span></md-list-item>

Expand All @@ -132,9 +129,6 @@

<md-divider></md-divider>
<md-subheader>{{ $t('other') }}</md-subheader>
<md-list-item to='/about'>
<md-icon>adb</md-icon>
<span class='md-list-item-text'>{{ $t('about') }}</span></md-list-item>
<md-list-item href='https://dev.nfls.io'>
<md-icon>developer_mode</md-icon>
<span class='md-list-item-text'>{{ $t('development') }}</span></md-list-item>
Expand All @@ -146,7 +140,7 @@
<md-divider></md-divider>
<md-subheader>{{ $t('admin') }}</md-subheader>

<md-list-item to='/admin/old'>
<md-list-item href='/admin/alumni/auth' target="_blank">
<md-icon>build</md-icon>
<span class='md-list-item-text'>{{ $t('console') }}</span></md-list-item>
<!--
Expand Down
6 changes: 4 additions & 2 deletions web/components/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<vue-markdown v-if="loaded">{{announcement}}</vue-markdown>
</md-card-content>
</md-card>
<!--
<md-card>
<md-card-header>
<div class="md-title">精选功能</div>
Expand All @@ -16,7 +17,7 @@
<md-empty-state
md-icon="pool"
md-description="新一代学习系统">
<md-button class="md-primary md-raised" disabled>划水(未开放)</md-button>
<md-button class="md-primary md-raised" href="https://water.nfls.io">划水</md-button>
</md-empty-state>
</div>
<div class="md-layout-item md-medium-size-25 md-small-size-50 md-xsmall-size-100">
Expand All @@ -30,7 +31,7 @@
<md-empty-state
md-icon="forum"
md-description="荒无人烟的地方">
<md-button class="md-primary md-raised" href="/forum">论坛</md-button>
<md-button class="md-primary md-raised" href="https://forum.nfls.io">论坛</md-button>
</md-empty-state>
</div>
<div class="md-layout-item md-medium-size-25 md-small-size-50 md-xsmall-size-100">
Expand All @@ -43,6 +44,7 @@
</div>
</md-card-content>
</md-card>
-->
</div>
</template>

Expand Down
Loading

0 comments on commit 382e79b

Please sign in to comment.