mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-05-22 08:36:51 +08:00
i18n 支持
This commit is contained in:
@@ -36,7 +36,7 @@ public class DefaultBasicAuthorizeDefinition implements AopAuthorizeDefinition {
|
||||
private ResourcesDefinition resources = new ResourcesDefinition();
|
||||
private DimensionsDefinition dimensions = new DimensionsDefinition();
|
||||
|
||||
private String message = "权限不足,拒绝访问";
|
||||
private String message = "error.access_denied";
|
||||
|
||||
private Phased phased;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
@AllArgsConstructor
|
||||
public class TwoFactorHandlerInterceptorAdapter extends HandlerInterceptorAdapter {
|
||||
|
||||
private TwoFactorValidatorManager validatorManager;
|
||||
private final TwoFactorValidatorManager validatorManager;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
@@ -45,9 +45,9 @@ public class TwoFactorHandlerInterceptorAdapter extends HandlerInterceptorAdapte
|
||||
code = request.getHeader(factor.parameter());
|
||||
}
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
throw new NeedTwoFactorException(factor.message(), factor.provider());
|
||||
throw new NeedTwoFactorException("assert.need_two_factor_verify", factor.provider());
|
||||
} else if (!validator.verify(code, factor.timeout())) {
|
||||
throw new NeedTwoFactorException("验证码错误", factor.provider());
|
||||
throw new NeedTwoFactorException(factor.message(), factor.provider());
|
||||
}
|
||||
}
|
||||
return super.preHandle(request, response, handler);
|
||||
|
||||
@@ -85,8 +85,8 @@ public class AuthorizationController {
|
||||
String username_ = (String) parameters.get("username");
|
||||
String password_ = (String) parameters.get("password");
|
||||
|
||||
Assert.hasLength(username_, "用户名不能为空");
|
||||
Assert.hasLength(password_, "密码不能为空");
|
||||
Assert.hasLength(username_, "assert.username_must_not_be_empty");
|
||||
Assert.hasLength(password_, "assert.password_must_not_be_empty");
|
||||
|
||||
Function<String, Object> parameterGetter = parameters::get;
|
||||
return Mono.defer(() -> {
|
||||
@@ -101,7 +101,7 @@ public class AuthorizationController {
|
||||
.publish(eventPublisher)
|
||||
.then(authenticationManager
|
||||
.authenticate(Mono.just(new PlainTextUsernamePasswordAuthenticationRequest(username, password)))
|
||||
.switchIfEmpty(Mono.error(() -> new AuthenticationException(AuthenticationException.ILLEGAL_PASSWORD,"密码错误")))
|
||||
.switchIfEmpty(Mono.error(() -> new AuthenticationException(AuthenticationException.ILLEGAL_PASSWORD)))
|
||||
.flatMap(auth -> {
|
||||
//触发授权成功事件
|
||||
AuthorizationSuccessEvent event = new AuthorizationSuccessEvent(auth, parameterGetter);
|
||||
|
||||
Reference in New Issue
Block a user