From ca2832d4e2bd917db71ebdbd0312528b163a6992 Mon Sep 17 00:00:00 2001 From: MaxKey Date: Sun, 27 Apr 2025 07:36:35 +0800 Subject: [PATCH] =?UTF-8?q?#IBY0OL=20=E9=95=BF=E6=97=B6=E9=97=B4=E6=9C=AA?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=EF=BC=8C=E9=AA=8C=E8=AF=81=E7=A0=81=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/contorller/ImageCaptchaEndpoint.java | 7 ++++--- .../app/routes/passport/login/login.component.ts | 14 ++++++++------ .../app/routes/passport/login/login.component.ts | 14 ++++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/maxkey-starter/maxkey-starter-captcha/src/main/java/org/dromara/maxkey/web/contorller/ImageCaptchaEndpoint.java b/maxkey-starter/maxkey-starter-captcha/src/main/java/org/dromara/maxkey/web/contorller/ImageCaptchaEndpoint.java index a8f15747c..e9629e596 100644 --- a/maxkey-starter/maxkey-starter-captcha/src/main/java/org/dromara/maxkey/web/contorller/ImageCaptchaEndpoint.java +++ b/maxkey-starter/maxkey-starter-captcha/src/main/java/org/dromara/maxkey/web/contorller/ImageCaptchaEndpoint.java @@ -78,10 +78,11 @@ public class ImageCaptchaEndpoint { } } String kaptchaKey = ""; - if(StringUtils.isNotBlank(state) - && !state.equalsIgnoreCase("state") - && authTokenService.validateJwtToken(state)) { + if(StringUtils.isNotBlank(state) && !state.equalsIgnoreCase("state")) { //just validate state Token + if(!authTokenService.validateJwtToken(state)) { + return new Message<>(Message.FAIL,"JwtToken is not Validate "); + } }else { state = authTokenService.genRandomJwt(); } diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts index 372692ede..71a45aadf 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts @@ -140,10 +140,7 @@ export class UserLoginComponent implements OnInit, OnDestroy { this.form.get('captcha')?.clearValidators(); } else { //init image captcha - this.imageCaptchaService.captcha({ state: this.state, captcha: this.captchaType }).subscribe(res => { - this.imageCaptcha = res.data.image; - this.cdr.detectChanges(); - }); + this.getImageCaptcha(); } } } @@ -206,8 +203,13 @@ export class UserLoginComponent implements OnInit, OnDestroy { // #region get captcha getImageCaptcha(): void { this.imageCaptchaService.captcha({ state: this.state, captcha: this.captchaType }).subscribe(res => { - this.imageCaptcha = res.data.image; - this.cdr.detectChanges(); + if (res.code == 0) { + this.imageCaptcha = res.data.image; + this.cdr.detectChanges(); + } else { + //令牌失效时,重新刷新页面 + window.location.reload(); + } }); } diff --git a/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts b/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts index 676a479fa..2b14967d8 100644 --- a/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts +++ b/maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts @@ -99,10 +99,7 @@ export class UserLoginComponent implements OnInit, OnDestroy { this.state = res.data.state; this.captchaType = res.data.captcha; //init image captcha - this.imageCaptchaService.captcha({ state: this.state, captcha: this.captchaType }).subscribe(res => { - this.imageCaptcha = res.data.image; - this.cdr.detectChanges(); - }); + this.getImageCaptcha(); } }); } @@ -113,8 +110,13 @@ export class UserLoginComponent implements OnInit, OnDestroy { getImageCaptcha(): void { this.imageCaptchaService.captcha({ state: this.state, captcha: this.captchaType }).subscribe(res => { - this.imageCaptcha = res.data.image; - this.cdr.detectChanges(); + if (res.code === 0) { + this.imageCaptcha = res.data.image; + this.cdr.detectChanges(); + } else { + //令牌失效时,重新刷新页面 + window.location.reload(); + } }); }