Authored by zhengyouwei

增加密码修改

@@ -13,13 +13,11 @@ import org.slf4j.Logger; @@ -13,13 +13,11 @@ import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Controller; 15 import org.springframework.stereotype.Controller;
16 -import org.springframework.ui.Model;  
17 import org.springframework.web.bind.annotation.RequestBody; 16 import org.springframework.web.bind.annotation.RequestBody;
18 import org.springframework.web.bind.annotation.RequestMapping; 17 import org.springframework.web.bind.annotation.RequestMapping;
19 import org.springframework.web.bind.annotation.ResponseBody; 18 import org.springframework.web.bind.annotation.ResponseBody;
20 import org.springframework.web.servlet.ModelAndView; 19 import org.springframework.web.servlet.ModelAndView;
21 20
22 -import javax.servlet.http.HttpSession;  
23 import java.util.HashMap; 21 import java.util.HashMap;
24 import java.util.Map; 22 import java.util.Map;
25 23
@@ -76,6 +74,9 @@ public class ManagerCtrl { @@ -76,6 +74,9 @@ public class ManagerCtrl {
76 @RequestMapping("/deleteUser") 74 @RequestMapping("/deleteUser")
77 @ResponseBody 75 @ResponseBody
78 public BaseResponse deleteUser(String name) { 76 public BaseResponse deleteUser(String name) {
  77 + if("admin".equals(name)){
  78 + return new BaseResponse(201, "此用户无法删除");
  79 + }
79 Map map = new HashMap<>(); 80 Map map = new HashMap<>();
80 map.put("name", name); 81 map.put("name", name);
81 BaseResponse response = httpRestClient.defaultGet(HttpUriContants.USER_DELETE_NAME, BaseResponse.class, map); 82 BaseResponse response = httpRestClient.defaultGet(HttpUriContants.USER_DELETE_NAME, BaseResponse.class, map);
@@ -34,6 +34,11 @@ public class UserCtrl { @@ -34,6 +34,11 @@ public class UserCtrl {
34 return new ModelAndView("user/login"); 34 return new ModelAndView("user/login");
35 } 35 }
36 36
  37 + @RequestMapping("/toupdatePwd")
  38 + public ModelAndView toupdatePwd() {
  39 + return new ModelAndView("user/modifypwd");
  40 + }
  41 +
37 @RequestMapping("/login") 42 @RequestMapping("/login")
38 public ModelAndView toLogin(User user, HttpSession session, Model model) { 43 public ModelAndView toLogin(User user, HttpSession session, Model model) {
39 User u = userAuthLocal.getUserByname(user.getName()); 44 User u = userAuthLocal.getUserByname(user.getName());
@@ -64,7 +69,7 @@ public class UserCtrl { @@ -64,7 +69,7 @@ public class UserCtrl {
64 public ModelAndView updatePwd(String name, String oldpwd, String newpwd, HttpSession session, Model model) { 69 public ModelAndView updatePwd(String name, String oldpwd, String newpwd, HttpSession session, Model model) {
65 Object obj = session.getAttribute("user"); 70 Object obj = session.getAttribute("user");
66 String username = String.valueOf(obj); 71 String username = String.valueOf(obj);
67 - if ("admin".equals(username)) { 72 + if ("admin".equals(username) && !"admin".equals(name)) {
68 User user = userAuthLocal.getUserByname(username); 73 User user = userAuthLocal.getUserByname(username);
69 if (user == null) { 74 if (user == null) {
70 model.addAttribute("message", "当前用户不存在"); 75 model.addAttribute("message", "当前用户不存在");
@@ -73,7 +78,7 @@ public class UserCtrl { @@ -73,7 +78,7 @@ public class UserCtrl {
73 user.setPwd(MD5Util.encryption(newpwd)); 78 user.setPwd(MD5Util.encryption(newpwd));
74 httpRestClient.defaultPost(HttpUriContants.USER_UPDATE_PWD, user, BaseResponse.class); 79 httpRestClient.defaultPost(HttpUriContants.USER_UPDATE_PWD, user, BaseResponse.class);
75 userAuthLocal.flushUser(name); 80 userAuthLocal.flushUser(name);
76 - return new ModelAndView("dashboard/toDashboard"); 81 + return new ModelAndView("dashboard/dashBoard");
77 82
78 } else if (name.equals(username)) { 83 } else if (name.equals(username)) {
79 User user = userAuthLocal.getUserByname(username); 84 User user = userAuthLocal.getUserByname(username);
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 var innerHTML = "<h5 style='color: #E0EEE0;font-style:oblique;font-weight:900;font-size:200%;margin-left: 45px;margin-top: 20px;'>YOHO</h5>"; 3 var innerHTML = "<h5 style='color: #E0EEE0;font-style:oblique;font-weight:900;font-size:200%;margin-left: 45px;margin-top: 20px;'>YOHO</h5>";
4 innerHTML += "<div id='user-nav'>"; 4 innerHTML += "<div id='user-nav'>";
5 innerHTML += "<ul class='nav btn-group'>"; 5 innerHTML += "<ul class='nav btn-group'>";
6 -innerHTML += "<li class='btn btn-inverse'><a href='#'><i class='icon icon-cog'></i> <span class='text'>Settings</span></a></li>"; 6 +innerHTML += "<li class='btn btn-inverse'><a id='changepwd_a' href='#'><i class='icon icon-cog'></i> <span class='text'>changePWD</span></a></li>";
7 innerHTML += "<li class='btn btn-inverse'><a id='logout_a' href='#'><i class='icon icon-share-alt'></i> <span class='text'>Logout</span></a></li>"; 7 innerHTML += "<li class='btn btn-inverse'><a id='logout_a' href='#'><i class='icon icon-share-alt'></i> <span class='text'>Logout</span></a></li>";
8 innerHTML += "</ul>"; 8 innerHTML += "</ul>";
9 innerHTML += "</div>"; 9 innerHTML += "</div>";
@@ -49,6 +49,7 @@ document.getElementById("li_nginxview_a").setAttribute("href", path + "/nginx/to @@ -49,6 +49,7 @@ document.getElementById("li_nginxview_a").setAttribute("href", path + "/nginx/to
49 document.getElementById("li_projectRelease_a").setAttribute("href", path + "/project/toProject"); 49 document.getElementById("li_projectRelease_a").setAttribute("href", path + "/project/toProject");
50 document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toDashboard"); 50 document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toDashboard");
51 document.getElementById("logout_a").setAttribute("href", path + "/user/logout"); 51 document.getElementById("logout_a").setAttribute("href", path + "/user/logout");
  52 +document.getElementById("changepwd_a").setAttribute("href", path + "/user/toupdatePwd");
52 document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toOthers"); 53 document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toOthers");
53 document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList"); 54 document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList");
54 document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser"); 55 document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser");