Explorar o código

Merge remote-tracking branch 'origin/3.0.x' into 3.0.x

zhouhao %!s(int64=6) %!d(string=hai) anos
pai
achega
580574f4dd

+ 7 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/TwoFactor.java

@@ -49,4 +49,11 @@ public @interface TwoFactor {
      * @return 关闭验证
      */
     boolean ignore() default false;
+
+    /**
+     *
+     * @return 错误提示
+     * @since 3.0.6
+     */
+    String message() default "需要进行双因子验证";
 }

+ 1 - 1
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/twofactor/TwoFactorHandlerInterceptorAdapter.java

@@ -45,7 +45,7 @@ public class TwoFactorHandlerInterceptorAdapter extends HandlerInterceptorAdapte
                 code = request.getHeader(factor.parameter());
             }
             if (StringUtils.isEmpty(code)) {
-                throw new NeedTwoFactorException("需要进行双重验证", factor.provider());
+                throw new NeedTwoFactorException(factor.message(), factor.provider());
             } else if (!validator.verify(code, factor.timeout())) {
                 throw new NeedTwoFactorException("验证码错误", factor.provider());
             }