去掉url中带有sessionid,记录免登录两周
This commit is contained in:
parent
7b3fe06d64
commit
ead0c57521
|
@ -78,10 +78,14 @@
|
||||||
layui.use('table', function () {
|
layui.use('table', function () {
|
||||||
var table = layui.table;
|
var table = layui.table;
|
||||||
//方法级渲染
|
//方法级渲染
|
||||||
|
var arr=[];
|
||||||
|
if(${leaveDetail}){
|
||||||
|
arr=${leaveDetail};
|
||||||
|
}
|
||||||
table.render({
|
table.render({
|
||||||
id: 'leaveDetail',
|
id: 'leaveDetail',
|
||||||
elem: '#leaveDetail'
|
elem: '#leaveDetail'
|
||||||
, data: ${leaveDetail}
|
, data:arr
|
||||||
, cols: [[
|
, cols: [[
|
||||||
{field: 'taskId', title: '任务编码', width: '20%'}
|
{field: 'taskId', title: '任务编码', width: '20%'}
|
||||||
,{field: 'opName', title: '审批人', width: '20%'}
|
,{field: 'opName', title: '审批人', width: '20%'}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.len.util.VerifyCodeUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.authc.ExcessiveAttemptsException;
|
import org.apache.shiro.authc.ExcessiveAttemptsException;
|
||||||
import org.apache.shiro.authc.IncorrectCredentialsException;
|
import org.apache.shiro.authc.IncorrectCredentialsException;
|
||||||
|
@ -39,6 +40,7 @@ public class LoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
SysUserService userService;
|
SysUserService userService;
|
||||||
private static final String CODE_ERROR = "code.error";
|
private static final String CODE_ERROR = "code.error";
|
||||||
|
private static final Long TWO_WEEK = 1000 * 60 * 60 * 24 * 14L;
|
||||||
|
|
||||||
@GetMapping(value = "")
|
@GetMapping(value = "")
|
||||||
public String login() {
|
public String login() {
|
||||||
|
@ -77,10 +79,10 @@ public class LoginController {
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public String login(SysUser user, Model model, String rememberMe, HttpServletRequest request) {
|
public String login(SysUser user, Model model, String rememberMe, HttpServletRequest request) {
|
||||||
String codeMsg = (String) request.getAttribute("shiroLoginFailure");
|
String codeMsg = (String) request.getAttribute("shiroLoginFailure");
|
||||||
/*if (CODE_ERROR.equals(codeMsg)) {
|
if (CODE_ERROR.equals(codeMsg)) {
|
||||||
model.addAttribute("message", "验证码错误");
|
model.addAttribute("message", "验证码错误");
|
||||||
return "/login2";
|
return "/login2";
|
||||||
}*/
|
}
|
||||||
CustomUsernamePasswordToken token = new CustomUsernamePasswordToken(user.getUsername().trim(),
|
CustomUsernamePasswordToken token = new CustomUsernamePasswordToken(user.getUsername().trim(),
|
||||||
user.getPassword(), LoginType.SYS);
|
user.getPassword(), LoginType.SYS);
|
||||||
Subject subject = Principal.getSubject();
|
Subject subject = Principal.getSubject();
|
||||||
|
@ -88,7 +90,13 @@ public class LoginController {
|
||||||
try {
|
try {
|
||||||
subject.login(token);
|
subject.login(token);
|
||||||
if (subject.isAuthenticated()) {
|
if (subject.isAuthenticated()) {
|
||||||
token.getUsername();
|
String isRemember = request.getParameter("isRemember");
|
||||||
|
if (!StringUtils.isEmpty(isRemember)) {
|
||||||
|
if ("true".equals(isRemember)) {
|
||||||
|
subject.getSession().setTimeout(TWO_WEEK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "redirect:/main";
|
return "redirect:/main";
|
||||||
}
|
}
|
||||||
} catch (UnknownAccountException | IncorrectCredentialsException e) {
|
} catch (UnknownAccountException | IncorrectCredentialsException e) {
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
<link rel="stylesheet" href="/plugin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="/plugin/layui/css/layui.css" media="all">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<script src="/plugin/login/hawkEye.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/plugin/login/jquery-core.min.js"></script>
|
<script type="text/javascript" src="/plugin/login/jquery-core.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugin/login/jquery-ui-core.min.js"></script>
|
<script type="text/javascript" src="/plugin/login/jquery-ui-core.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugin/login/fai.min.js"></script>
|
<script type="text/javascript" src="/plugin/login/fai.min.js"></script>
|
||||||
|
@ -55,6 +54,7 @@
|
||||||
<span class="icon icon-3"></span>
|
<span class="icon icon-3"></span>
|
||||||
<input name="password" lay-verify="password" type="password" id="loginPwd" placeholder="请输入密码" maxlength="20">
|
<input name="password" lay-verify="password" type="password" id="loginPwd" placeholder="请输入密码" maxlength="20">
|
||||||
<input type="text" id="loginPwdText" placeholder="请输入密码" maxlength="20" class="hide">
|
<input type="text" id="loginPwdText" placeholder="请输入密码" maxlength="20" class="hide">
|
||||||
|
<input type="hidden" id="isRemember" name="isRemember" value="false"/>
|
||||||
<span class="icon icon-4"></span>
|
<span class="icon icon-4"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="validatePanel" class="item" style="width: 137px;">
|
<div id="validatePanel" class="item" style="width: 137px;">
|
||||||
|
@ -66,11 +66,8 @@
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
<span class="icon-nocheck" id="autoLogin"></span>
|
<span class="icon-nocheck" id="autoLogin"></span>
|
||||||
<span class="login-tip">两周内自动登录</span>
|
<span class="login-tip">两周内自动登录</span>
|
||||||
<a href="javascript:" onclick="openPassword()" class="no-pwd">忘记密码?</a>
|
<!-- <a href="javascript:" onclick="openPassword()" class="no-pwd">忘记密码?</a>-->
|
||||||
</div>
|
</div>
|
||||||
<!--<div id="loginBtn" lay-filter="login" lay-submit class="deal" >
|
|
||||||
立即登录
|
|
||||||
</div>-->
|
|
||||||
<div style="width: 300px;height: 50px;text-align: center;margin: 24px auto 0;">
|
<div style="width: 300px;height: 50px;text-align: center;margin: 24px auto 0;">
|
||||||
<input id="loginBtn" class="deal" value="立即登录" lay-submit lay-filter="login" type="submit">
|
<input id="loginBtn" class="deal" value="立即登录" lay-submit lay-filter="login" type="submit">
|
||||||
</div>
|
</div>
|
||||||
|
@ -88,9 +85,16 @@
|
||||||
|
|
||||||
|
|
||||||
// 是否两周内自动登录
|
// 是否两周内自动登录
|
||||||
/* $('.icon-nocheck, .login-tip').click(function () {
|
$('.icon-nocheck, .login-tip').click(function () {
|
||||||
$('.icon-nocheck').toggleClass('icon-check');
|
$('.icon-nocheck').toggleClass('icon-check');
|
||||||
});*/
|
var isRemember=$('#isRemember').val();
|
||||||
|
if(isRemember==='false'){
|
||||||
|
isRemember='true';
|
||||||
|
}else{
|
||||||
|
isRemember='false'
|
||||||
|
}
|
||||||
|
$('#isRemember').val(isRemember);
|
||||||
|
});
|
||||||
layui.use(['form','layer'], function(){
|
layui.use(['form','layer'], function(){
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
form.verify({
|
form.verify({
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,62 +0,0 @@
|
||||||
package com.len.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class RConfig {
|
|
||||||
@Value("${spring.redis.port}")
|
|
||||||
private String host;
|
|
||||||
|
|
||||||
@Value("${spring.redis.port}")
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
@Value("${spring.redis.timeout}")
|
|
||||||
private int timeout;
|
|
||||||
|
|
||||||
@Value("${spring.redis.maxRetryCount}")
|
|
||||||
private int maxRetryCount;
|
|
||||||
|
|
||||||
@Value("${spring.redis.second}")
|
|
||||||
private Long second;
|
|
||||||
|
|
||||||
public String getHost() {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHost(String host) {
|
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(int port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTimeout() {
|
|
||||||
return timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeout(int timeout) {
|
|
||||||
this.timeout = timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxRetryCount() {
|
|
||||||
return maxRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxRetryCount(int maxRetryCount) {
|
|
||||||
this.maxRetryCount = maxRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSecond() {
|
|
||||||
return second;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSecond(Long second) {
|
|
||||||
this.second = second;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,8 +19,8 @@ import org.crazycake.shiro.RedisCacheManager;
|
||||||
import org.crazycake.shiro.RedisManager;
|
import org.crazycake.shiro.RedisManager;
|
||||||
import org.crazycake.shiro.RedisSessionDAO;
|
import org.crazycake.shiro.RedisSessionDAO;
|
||||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -41,8 +41,12 @@ import java.util.*;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ShiroConfig {
|
public class ShiroConfig {
|
||||||
|
|
||||||
@Autowired
|
@Value("${spring.redis.host}")
|
||||||
RConfig redisConfig;
|
private String host;
|
||||||
|
@Value("${spring.redis.port}")
|
||||||
|
private int port;
|
||||||
|
@Value("${spring.redis.timeout}")
|
||||||
|
private int timeout;
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -86,7 +90,7 @@ public class ShiroConfig {
|
||||||
/*==========ehcache 缓存 end============*/
|
/*==========ehcache 缓存 end============*/
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
|
public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
|
||||||
return new LifecycleBeanPostProcessor();
|
return new LifecycleBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +156,7 @@ public class ShiroConfig {
|
||||||
filterMap.put("/login", "verCode,anon");
|
filterMap.put("/login", "verCode,anon");
|
||||||
filterMap.put("/blogLogin", "verCode,anon");
|
filterMap.put("/blogLogin", "verCode,anon");
|
||||||
filterMap.put("/getCode", "anon");
|
filterMap.put("/getCode", "anon");
|
||||||
|
filterMap.put("/oauth", "anon");
|
||||||
filterMap.put("/actuator/**", "anon");
|
filterMap.put("/actuator/**", "anon");
|
||||||
filterMap.put("/eureka/**", "anon");
|
filterMap.put("/eureka/**", "anon");
|
||||||
filterMap.put("/img/**", "anon");
|
filterMap.put("/img/**", "anon");
|
||||||
|
@ -192,24 +197,23 @@ public class ShiroConfig {
|
||||||
|
|
||||||
public RedisCacheManager cacheManager() {
|
public RedisCacheManager cacheManager() {
|
||||||
RedisCacheManager redisCacheManager = new RedisCacheManager();
|
RedisCacheManager redisCacheManager = new RedisCacheManager();
|
||||||
redisCacheManager.setRedisManager(redisManager());
|
redisCacheManager.setRedisManager(getRedisManager());
|
||||||
redisCacheManager.setPrincipalIdFieldName("id");
|
redisCacheManager.setPrincipalIdFieldName("id");
|
||||||
return redisCacheManager;
|
return redisCacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RedisManager redisManager() {
|
// @Bean
|
||||||
|
public RedisManager getRedisManager() {
|
||||||
RedisManager redisManager = new RedisManager();
|
RedisManager redisManager = new RedisManager();
|
||||||
// redisManager.setHost(redisConfig.getHost());
|
redisManager.setHost(host + ":" + port);
|
||||||
// redisManager.setPort(redisConfig.getPort());
|
redisManager.setTimeout(timeout);
|
||||||
// redisManager.setExpire(1800);
|
|
||||||
// redisManager.setTimeout(redisConfig.getTimeout());
|
|
||||||
return redisManager;
|
return redisManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisSessionDAO redisSessionDAO() {
|
public RedisSessionDAO redisSessionDAO() {
|
||||||
RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
|
RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
|
||||||
redisSessionDAO.setRedisManager(redisManager());
|
redisSessionDAO.setRedisManager(getRedisManager());
|
||||||
return redisSessionDAO;
|
return redisSessionDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +221,7 @@ public class ShiroConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public DefaultWebSessionManager sessionManager() {
|
public DefaultWebSessionManager sessionManager() {
|
||||||
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
|
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
|
||||||
|
sessionManager.setSessionIdUrlRewritingEnabled(false);
|
||||||
sessionManager.setSessionDAO(redisSessionDAO());
|
sessionManager.setSessionDAO(redisSessionDAO());
|
||||||
return sessionManager;
|
return sessionManager;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue