From bd0688dda865a73b7a8fdaa992aebb97c67bfc1b Mon Sep 17 00:00:00 2001 From: npmrun Date: Tue, 13 Sep 2022 10:13:51 +0800 Subject: [PATCH] fixed bug --- public/image/icons/error.svg | 1 + source/db/data.db | Bin 81920 -> 81920 bytes source/route/views/login.ts | 6 +++++- template/helper/flush.pug | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 public/image/icons/error.svg diff --git a/public/image/icons/error.svg b/public/image/icons/error.svg new file mode 100644 index 0000000..658f161 --- /dev/null +++ b/public/image/icons/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/db/data.db b/source/db/data.db index f5c37205b18260b488a18b101114f304726aa058..308def576748eb7b0fc6594a842bafed741ce3d4 100644 GIT binary patch delta 184 zcmZo@U~On%ogmGaFj2;tF=1mufjuMJ=8N{m3;0-hIT-jZ^Xc)I@^8WCrq+)2GVo_O^l~b7FUr`ug5MorGTpUprW$2%07U}BjW18U?>1kjY zQ5uyKQIX-3sGpiyY7miA7Hni-WTb0gscUGgU|?uvYG`F>u4iIlte|aRU}a!{Tb2bR Ky}A2sX%GO8_A#db delta 49 zcmZo@U~On%ogmE^KT*b+F@9r0fjuMZ=8N{m3wT&~yBYW{^Xc)I@^)_)6sYFi-2JvR F2mpPV5Ags1 diff --git a/source/route/views/login.ts b/source/route/views/login.ts index ac58d31..dc2e978 100644 --- a/source/route/views/login.ts +++ b/source/route/views/login.ts @@ -17,7 +17,7 @@ export default class { } else { logger.debug("未登录"); } - return h.view("views/login.pug"); + return h.view("views/login.pug"); } @method("POST") @@ -25,6 +25,10 @@ export default class { @auth(false) async loginRes(request: Req, h: Res): ReturnValue { const { username, password } = request.payload as any; + if(!username || !password ){ + request.yar.flash('error', 'username or password can not be empty.'); + return h.redirect("/login"); + } const User = request.getModel("User"); const account = await User.findOne({ where: { username: username } }); diff --git a/template/helper/flush.pug b/template/helper/flush.pug index a58db37..2e1ace1 100644 --- a/template/helper/flush.pug +++ b/template/helper/flush.pug @@ -4,9 +4,9 @@ if flash&&flash.error each item in flash.error .toast.show(role='alert', aria-live='assertive', aria-atomic='true') .toast-header - img.rounded.me-2(src='...', alt='错误') + img.rounded.me-2(src='/public/image/icons/error.svg', alt='错误' style="width:20px;height: 20px;") strong.me-auto 提示 - small.text-muted just now + //- small.text-muted just now button.btn-close(type='button', data-bs-dismiss='toast', aria-label='Close') .toast-body. #{item}