未验证 提交 8142e364 编写于 作者: journey2018's avatar journey2018 提交者: GitHub

fix bug. Client ip changes, sessionId cannot be accessed modify(#622) (#653)

* Filtering the log of one task to the log of another task

* Filtering the log of one task to the log of another task update

* rollback

* The log shows confusion

* update loggerserver

* update

* datasource connect error modify

* rollback code,logger server log filter ,process variables modify local variables

* Client ip changes, sessionId cannot be accessed modify
上级 244bdd96
......@@ -68,7 +68,7 @@ public class SessionService extends BaseService{
String ip = BaseController.getClientIpAddress(request);
logger.info("get session: {}, ip: {}", sessionId, ip);
return sessionMapper.queryByIdAndIp(sessionId, ip);
return sessionMapper.queryBySessionId(sessionId);
}
/**
......@@ -80,7 +80,7 @@ public class SessionService extends BaseService{
*/
public String createSession(User user, String ip) {
// logined
Session session = sessionMapper.queryByUserIdAndIp(user.getId(), ip);
Session session = sessionMapper.queryByUserId(user.getId());
Date now = new Date();
/**
......@@ -126,7 +126,7 @@ public class SessionService extends BaseService{
/**
* query session by user id and ip
*/
Session session = sessionMapper.queryByUserIdAndIp(loginUser.getId(), ip);
Session session = sessionMapper.queryByUserId(loginUser.getId());
//delete session
sessionMapper.deleteById(session.getId());
}
......
......@@ -57,25 +57,10 @@ public interface SessionMapper {
int update(@Param("sessionId") String sessionId, @Param("loginTime") Date loginTime);
/**
* query by session id
* @param sessionId
* @return
*/
@Results(value = {@Result(property = "id", column = "id", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "ip", column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "lastLoginTime", column = "last_login_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = SessionMapperProvider.class, method = "queryById")
Session queryById(@Param("sessionId") int sessionId);
/**
* query by session id and ip
*
* @param sessionId
* @param ip
* @return
*/
@Results(value = {
......@@ -84,14 +69,13 @@ public interface SessionMapper {
@Result(property = "ip", column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "lastLoginTime", column = "last_login_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = SessionMapperProvider.class, method = "queryByIdAndIp")
Session queryByIdAndIp(@Param("sessionId") String sessionId, @Param("ip") String ip);
@SelectProvider(type = SessionMapperProvider.class, method = "queryBySessionId")
Session queryBySessionId(@Param("sessionId") String sessionId);
/**
* query by user id and ip
* @param userId
* @param ip
* @return
*/
@Results(value = {
......@@ -100,7 +84,7 @@ public interface SessionMapper {
@Result(property = "ip", column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "lastLoginTime", column = "last_login_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = SessionMapperProvider.class, method = "queryByUserIdAndIp")
Session queryByUserIdAndIp(@Param("userId") int userId, @Param("ip") String ip);
@SelectProvider(type = SessionMapperProvider.class, method = "queryByUserId")
Session queryByUserId(@Param("userId") int userId);
}
......@@ -107,14 +107,13 @@ public class SessionMapperProvider {
* @param parameter
* @return
*/
public String queryByIdAndIp(Map<String, Object> parameter) {
public String queryBySessionId(Map<String, Object> parameter) {
return new SQL() {{
SELECT("*");
FROM(TABLE_NAME);
WHERE("`id` = #{sessionId}");
WHERE("`ip` = #{ip}");
}}.toString();
}
......@@ -123,14 +122,13 @@ public class SessionMapperProvider {
* @param parameter
* @return
*/
public String queryByUserIdAndIp(Map<String, Object> parameter) {
public String queryByUserId(Map<String, Object> parameter) {
return new SQL() {{
SELECT("*");
FROM(TABLE_NAME);
WHERE("`user_id` = #{userId}");
WHERE("`ip` = #{ip}");
}}.toString();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册