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