mirror of
https://github.com/apache/rocketmq-dashboard.git
synced 2025-09-11 03:49:06 +08:00
Fix the issue caused by server.servlet.context-path when logging
This commit is contained in:
@@ -22,10 +22,12 @@ import org.apache.rocketmq.console.model.LoginInfo;
|
|||||||
import org.apache.rocketmq.console.model.User;
|
import org.apache.rocketmq.console.model.User;
|
||||||
import org.apache.rocketmq.console.model.UserInfo;
|
import org.apache.rocketmq.console.model.UserInfo;
|
||||||
import org.apache.rocketmq.console.service.UserService;
|
import org.apache.rocketmq.console.service.UserService;
|
||||||
|
import org.apache.rocketmq.console.support.JsonResult;
|
||||||
import org.apache.rocketmq.console.util.WebUtil;
|
import org.apache.rocketmq.console.util.WebUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@@ -47,6 +49,9 @@ public class LoginController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
|
@Value("${server.servlet.context-path:/}")
|
||||||
|
private String contextPath;
|
||||||
|
|
||||||
@RequestMapping(value = "/check.query", method = RequestMethod.GET)
|
@RequestMapping(value = "/check.query", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object check(HttpServletRequest request) {
|
public Object check(HttpServletRequest request) {
|
||||||
@@ -60,7 +65,7 @@ public class LoginController {
|
|||||||
|
|
||||||
@RequestMapping(value = "/login.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/login.do", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object login(@RequestParam("username") String username,
|
public JsonResult<String> login(@RequestParam("username") String username,
|
||||||
@RequestParam(value = "password") String password,
|
@RequestParam(value = "password") String password,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response) throws Exception {
|
HttpServletResponse response) throws Exception {
|
||||||
@@ -75,16 +80,14 @@ public class LoginController {
|
|||||||
WebUtil.setSessionValue(request, WebUtil.USER_INFO, userInfo);
|
WebUtil.setSessionValue(request, WebUtil.USER_INFO, userInfo);
|
||||||
WebUtil.setSessionValue(request, WebUtil.USER_NAME, username);
|
WebUtil.setSessionValue(request, WebUtil.USER_NAME, username);
|
||||||
userInfo.setSessionId(WebUtil.getSessionId(request));
|
userInfo.setSessionId(WebUtil.getSessionId(request));
|
||||||
|
return new JsonResult<>(contextPath);
|
||||||
return userInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/logout.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/logout.do", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object logout(HttpServletRequest request) {
|
public JsonResult<String> logout(HttpServletRequest request) {
|
||||||
WebUtil.removeSession(request);
|
WebUtil.removeSession(request);
|
||||||
|
return new JsonResult<>(contextPath);
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ var app = angular.module('app', [
|
|||||||
if (initFlag) return;
|
if (initFlag) return;
|
||||||
initFlag = true;
|
initFlag = true;
|
||||||
|
|
||||||
var url = '/login/check.query';
|
var url = 'login/check.query';
|
||||||
var setting = {
|
var setting = {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
timeout:15000,
|
timeout:15000,
|
||||||
@@ -110,10 +110,9 @@ var app = angular.module('app', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.factory('abc', function ($http, $window) {
|
app.factory('abc', function ($http, $window) {
|
||||||
console.log('xxxxxxx');
|
|
||||||
$http({
|
$http({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/login/check.query"
|
url: "login/check.query"
|
||||||
}).success(function (resp) {
|
}).success(function (resp) {
|
||||||
if (resp.status == 0) {
|
if (resp.status == 0) {
|
||||||
alert(resp.data)
|
alert(resp.data)
|
||||||
|
@@ -24,7 +24,7 @@ app.controller('AppCtrl', ['$scope','$window','$translate','$http','Notification
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
url: "login/logout.do"
|
url: "login/logout.do"
|
||||||
}).success(function (resp) {
|
}).success(function (resp) {
|
||||||
window.location = "/";
|
window.location = resp.data;
|
||||||
$window.sessionStorage.clear();
|
$window.sessionStorage.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -34,9 +34,7 @@ app.controller('loginController', ['$scope','$location','$http','Notification','
|
|||||||
if (resp.status == 0) {
|
if (resp.status == 0) {
|
||||||
Notification.info({message: 'Login successful, redirect now', delay: 2000});
|
Notification.info({message: 'Login successful, redirect now', delay: 2000});
|
||||||
$window.sessionStorage.setItem("username", $("#username").val());
|
$window.sessionStorage.setItem("username", $("#username").val());
|
||||||
//alert("XXXXX resp.data="+resp.data.sessionId);
|
window.location = resp.data;
|
||||||
//$window.sessionStorage.setItem("sessionId", resp.data.sessionId);
|
|
||||||
window.location = "/";
|
|
||||||
initFlag = false;
|
initFlag = false;
|
||||||
} else{
|
} else{
|
||||||
Notification.error({message: resp.errMsg, delay: 2000});
|
Notification.error({message: resp.errMsg, delay: 2000});
|
||||||
|
Reference in New Issue
Block a user