Skip to content

Commit

Permalink
扫描文件改动的时间间隔调为 30 秒,托管给 gretty/spring-loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Fireply committed May 30, 2016
1 parent 6262c0b commit 06d1585
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ task wrapper(type: Wrapper) {
gretty {
servletContainer = 'tomcat8'
httpPort = 9080
scanInterval = 0
scanInterval = 30
managedClassReload = true
}

repositories {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/fireply/enter/action/LoginAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.fireply.enter.security.Md5;
import org.fireply.enter.security.Sign;
import org.fireply.enter.service.LoginService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
Expand All @@ -46,6 +48,8 @@ public class LoginAction extends ActionSupport implements ServletRequestAware, S
// 登录页面填写的 userId, 不止是和 数据库里 user 表的 id 挂钩,还和 admin 表的 id 挂钩
private String userId;
private String userPassword; // 登录页面填写的 userPassword

private static final Logger logger = LoggerFactory.getLogger(LoginAction.class);

@Override
public String execute() throws Exception {
Expand All @@ -61,6 +65,7 @@ public String execute() throws Exception {
String cookieToken = null;

if (userId != null && userPassword != null) {
logger.debug("用户/管理员 {} 使用密码登录", userId);
String signedPassword = Md5.md5(userPassword);
loginResult = loginService.loginByPassword(userId, signedPassword, remoteAddr);
} else if (cookies != null) {
Expand All @@ -86,9 +91,11 @@ public String execute() throws Exception {

if (found) { // 使用 Cookie 登陆
if (cookieAdminId != null && cookieAdminId.length() > 0) {
logger.debug("管理员 {} 使用 Cookie 登录", cookieAdminId);
loginResult = loginService.loginByCookie(cookieAdminId, cookieSequence, cookieToken,
remoteAddr);
} else {
logger.debug("用户 {} 使用 Cookie 登录", cookieUserId);
loginResult = loginService.loginByCookie(cookieUserId, cookieSequence, cookieToken,
remoteAddr);
}
Expand All @@ -101,6 +108,7 @@ public String execute() throws Exception {

// 如果登录成功
if (SUCCESS_USER.equals(loginResult)) {
logger.info("用户 {} 通过密码登录成功", userId);
updateUserAuthorization(userId);
//TODO
if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) {
Expand All @@ -109,6 +117,7 @@ public String execute() throws Exception {
return PROFILE_USER;
}
} else if (SUCCESS_COOKIE_USER.equals(loginResult)) {
logger.info("用户 {} 通过 Cookie 登录成功", cookieUserId);
updateUserAuthorization(cookieUserId);
//TODO
if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) {
Expand All @@ -117,13 +126,15 @@ public String execute() throws Exception {
return PROFILE_USER;
}
}else if (SUCCESS_ADMIN.equals(loginResult)) {
logger.info("管理员 {} 通过密码登录成功", userId);
updateAdminAuthorization(userId); // 前台页面 userId 与 adminId 共用一个 name="userId" 的 <input> 标签
if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) {
return actionPath;//TODO
} else {
return PROFILE_ADMIN;
}
} else if (SUCCESS_COOKIE_ADMIN.equals(loginResult)) {
logger.info("管理员 {} 通过 Cookie 登录成功", cookieAdminId);
updateAdminAuthorization(cookieAdminId);
if (actionPath != null && actionPath.length() > 0 && !"/login".equals(actionPath)) {
return actionPath;//TODO
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender" debug="true" scan="true" scanPeriod="15 seconds">
<appender name="console" class="ch.qos.logback.core.ConsoleAppender" debug="true">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
Expand Down

0 comments on commit 06d1585

Please sign in to comment.