|
@@ -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)
|
|
|
{
|
|
|
|
|
|
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";
|
|
|
}
|
|
|
|