From bb242ec32108aa23a8aafc91df8cbaf137b91157 Mon Sep 17 00:00:00 2001 From: iGeeky Date: Sun, 18 Jun 2023 17:43:02 +0800 Subject: [PATCH] dashboard login with captcha --- console/src/api/user.js | 8 ++ console/src/i18n/langs/en.js | 2 + console/src/i18n/langs/zh-cn.js | 2 + console/src/icons/svg/refresh.svg | 1 + console/src/views/login/index.vue | 99 +++++++++++++++++++++- docs/deploy-cn.md | 1 + docs/deploy.md | 3 +- server/conf/config.js | 1 + server/package.json | 1 + server/src/controllers/captcha.js | 25 ++++++ server/src/controllers/user.js | 11 +++ server/src/middlewares/token-check.js | 1 + server/src/util/captcha-util.js | 53 ++++++++++++ server/test/24.captcha.test.js | 117 ++++++++++++++++++++++++++ 14 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 console/src/icons/svg/refresh.svg create mode 100644 server/src/controllers/captcha.js create mode 100644 server/src/util/captcha-util.js create mode 100644 server/test/24.captcha.test.js diff --git a/console/src/api/user.js b/console/src/api/user.js index 954a71c..6475652 100644 --- a/console/src/api/user.js +++ b/console/src/api/user.js @@ -60,6 +60,14 @@ export async function getLoginOptions() { }) } +export async function getCaptchaData() { + return await request({ + url: '/captcha', + method: 'get', + params: { }, + }) +} + export async function listUsers(args) { return await request({ url: '/user/list', diff --git a/console/src/i18n/langs/en.js b/console/src/i18n/langs/en.js index 3675ac5..db201a7 100644 --- a/console/src/i18n/langs/en.js +++ b/console/src/i18n/langs/en.js @@ -87,6 +87,7 @@ const en = { 'loginPromptUsername': 'Username', 'loginPromptPassword': 'Password', + 'loginPromptCaptcha': 'Captcha', 'loginPromptLoginForm': 'Console Login', 'loginPromptStandardLogin': 'Standard', @@ -248,6 +249,7 @@ const en = { 'ERR_USERNAME_MISSING': 'Username missing!', 'ERR_PASSWORD_MISSING': 'Password missing!', + 'ERR_CAPTCHA_INVALID': 'captcha error', 'ERR_APPID_NOT_FOUND': 'Appid not found!', 'ERR_USER_NOT_FOUND': 'User not found', 'ERR_PASSWORD_ERROR': 'Password error', diff --git a/console/src/i18n/langs/zh-cn.js b/console/src/i18n/langs/zh-cn.js index e643747..c373fe3 100644 --- a/console/src/i18n/langs/zh-cn.js +++ b/console/src/i18n/langs/zh-cn.js @@ -87,6 +87,7 @@ const zhcn = { 'loginPromptUsername': '用户名', 'loginPromptPassword': '密码', + 'loginPromptCaptcha': '验证码', 'loginPromptLoginForm': '控制台登录', 'loginPromptStandardLogin': '标准登录', @@ -248,6 +249,7 @@ const zhcn = { 'ERR_USERNAME_MISSING': '缺少用户名', 'ERR_PASSWORD_MISSING': '缺少密码', + 'ERR_CAPTCHA_INVALID': '验证码错误', 'ERR_APPID_NOT_FOUND': 'Appid不存在', 'ERR_USER_NOT_FOUND': '用户不存在', 'ERR_PASSWORD_ERROR': '密码错误', diff --git a/console/src/icons/svg/refresh.svg b/console/src/icons/svg/refresh.svg new file mode 100644 index 0000000..de7f665 --- /dev/null +++ b/console/src/icons/svg/refresh.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/console/src/views/login/index.vue b/console/src/views/login/index.vue index 9634609..85b1d7f 100644 --- a/console/src/views/login/index.vue +++ b/console/src/views/login/index.vue @@ -45,6 +45,23 @@ + +
+ +
+
+ {{ countdownNum }} +
+ +
+ @@ -69,7 +86,7 @@