fix: 修复session超时时间配置单位错误的问题
This commit is contained in:
parent
b9dc780292
commit
17bd707efa
|
@ -43,6 +43,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -200,8 +201,8 @@ public class SSOService {
|
|||
session.getAttributes().put("authId", authSource.getId());
|
||||
session.getAttributes().put("casTicket", ticket);
|
||||
// 记录cas对应关系
|
||||
Long timeout = env.getProperty("spring.session.timeout", Long.class);
|
||||
stringRedisTemplate.opsForValue().set(ticket, name, timeout, TimeUnit.SECONDS);
|
||||
Duration timeout = env.getProperty("spring.session.timeout", Duration.class, Duration.ofHours(12));
|
||||
stringRedisTemplate.opsForValue().set(ticket, name, timeout);
|
||||
|
||||
return userOptional;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class SystemParameterController {
|
|||
|
||||
@GetMapping("timeout")
|
||||
public long getTimeout() {
|
||||
return env.getProperty("spring.session.timeout", Long.class, 43200L); // 默认43200s, 12个小时
|
||||
return env.getProperty("spring.session.timeout", Duration.class, Duration.ofHours(12)).getSeconds(); // 默认43200s, 12个小时
|
||||
}
|
||||
|
||||
@GetMapping("/mail/info")
|
||||
|
|
Loading…
Reference in New Issue