|
@@ -22,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.hswebframework.web.BusinessException;
|
|
|
import org.hswebframework.web.NotFoundException;
|
|
|
+import org.hswebframework.web.WebUtil;
|
|
|
import org.hswebframework.web.authorization.Authentication;
|
|
|
import org.hswebframework.web.authorization.annotation.Authorize;
|
|
|
import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
|
|
@@ -47,26 +48,12 @@ import static org.hswebframework.web.controller.message.ResponseMessage.ok;
|
|
|
@Api(tags = "hsweb-authorization", description = "提供基本的授权功能")
|
|
|
public class AuthorizationController {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
@Autowired
|
|
|
private AuthorizationListenerDispatcher authorizationListenerDispatcher;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@GetMapping("/login-out")
|
|
|
@AccessLogger("退出登录")
|
|
|
@Authorize
|
|
@@ -93,34 +80,6 @@ public class AuthorizationController {
|
|
|
|
|
|
AuthorizationBeforeEvent beforeEvent = new AuthorizationBeforeEvent(username, password, parameterGetter);
|
|
|
authorizationListenerDispatcher.doEvent(beforeEvent);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
UserEntity entity = userService.selectByUsername(username);
|
|
|
if (entity == null) {
|
|
|
reason = AuthorizationFailedEvent.Reason.USER_NOT_EXISTS;
|
|
@@ -135,8 +94,8 @@ public class AuthorizationController {
|
|
|
reason = AuthorizationFailedEvent.Reason.PASSWORD_ERROR;
|
|
|
throw new BusinessException("{password_error}", 400);
|
|
|
}
|
|
|
-
|
|
|
- userService.updateLoginInfo(entity.getId(), "", System.currentTimeMillis());
|
|
|
+
|
|
|
+ userService.updateLoginInfo(entity.getId(), WebUtil.getIpAddr(request), System.currentTimeMillis());
|
|
|
|
|
|
Authentication authentication = userService.initUserAuthorization(entity.getId());
|
|
|
AuthorizationSuccessEvent event = new AuthorizationSuccessEvent(authentication, parameterGetter);
|
|
@@ -147,10 +106,6 @@ public class AuthorizationController {
|
|
|
failedEvent.setException(e);
|
|
|
authorizationListenerDispatcher.doEvent(failedEvent);
|
|
|
throw e;
|
|
|
- } finally {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|