|
|
@@ -3,17 +3,14 @@ package com.uas.sso.sso.backend.api;
|
|
|
import com.uas.sso.sso.backend.entity.Admin;
|
|
|
import com.uas.sso.sso.backend.service.AdminService;
|
|
|
import com.uas.sso.sso.backend.support.MD5Utils;
|
|
|
-import com.uas.sso.sso.backend.support.ResultBean;
|
|
|
import java.util.Objects;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.Assert;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
@Controller
|
|
|
public class LoginController {
|
|
|
@@ -25,11 +22,20 @@ public class LoginController {
|
|
|
this.adminService = adminService;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 管理员登录接口,兼容测试环境和发布环境
|
|
|
+ *
|
|
|
+ * @param userName 管理员账号
|
|
|
+ * @param password 密码
|
|
|
+ * @param request Http请求
|
|
|
+ */
|
|
|
@RequestMapping(method = {RequestMethod.POST, RequestMethod.GET}, path = "/api/login", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
public String login(String userName, String password, HttpServletRequest request) {
|
|
|
+ String origin = request.getHeader("origin");
|
|
|
+
|
|
|
try {
|
|
|
if ("GET".equals(request.getMethod())) {
|
|
|
- return "redirect:/login";
|
|
|
+ return String.format("redirect:%s/login", origin);
|
|
|
}
|
|
|
|
|
|
Assert.hasText(userName, "用户名不能为空");
|
|
|
@@ -42,11 +48,11 @@ public class LoginController {
|
|
|
|
|
|
if (status) {
|
|
|
request.getSession(true).setAttribute("account", admin);
|
|
|
- return "redirect:/index";
|
|
|
+ return String.format("redirect:%s/index", origin);
|
|
|
}
|
|
|
- return "redirect:/login";
|
|
|
+ return String.format("redirect:%s/login", origin);
|
|
|
} catch (Exception e) {
|
|
|
- return "redirect:/login";
|
|
|
+ return String.format("redirect:%s/login", origin);
|
|
|
}
|
|
|
}
|
|
|
}
|