支持配置是否开启记住我功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.web.controller.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -103,9 +104,10 @@ public class CommonController
|
||||
{
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (MultipartFile file : files) {
|
||||
List<String> fileNames = new ArrayList<String>();
|
||||
List<String> urls = new ArrayList<String>();
|
||||
for (MultipartFile file : files)
|
||||
{
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
@@ -151,4 +153,4 @@ public class CommonController
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,10 @@ import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@@ -14,6 +17,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.ConfigService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
@@ -23,15 +27,27 @@ import com.ruoyi.common.utils.StringUtils;
|
||||
@Controller
|
||||
public class SysLoginController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 是否开启记住我功能
|
||||
*/
|
||||
@Value("${shiro.rememberMe.enabled: false}")
|
||||
private boolean rememberMe;
|
||||
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login(HttpServletRequest request, HttpServletResponse response)
|
||||
public String login(HttpServletRequest request, HttpServletResponse response, ModelMap mmap)
|
||||
{
|
||||
// 如果是Ajax请求,返回Json字符串。
|
||||
if (ServletUtils.isAjaxRequest(request))
|
||||
{
|
||||
return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
|
||||
}
|
||||
|
||||
// 是否开启记住我
|
||||
mmap.put("isRemembered", rememberMe);
|
||||
// 是否开启用户注册
|
||||
mmap.put("isAllowRegister", configService.getKey("sys.account.registerUser"));
|
||||
return "login";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user