Authored by zhengyouwei

增加密码修改

... ... @@ -13,13 +13,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
... ... @@ -76,6 +74,9 @@ public class ManagerCtrl {
@RequestMapping("/deleteUser")
@ResponseBody
public BaseResponse deleteUser(String name) {
if("admin".equals(name)){
return new BaseResponse(201, "此用户无法删除");
}
Map map = new HashMap<>();
map.put("name", name);
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.USER_DELETE_NAME, BaseResponse.class, map);
... ...
... ... @@ -34,6 +34,11 @@ public class UserCtrl {
return new ModelAndView("user/login");
}
@RequestMapping("/toupdatePwd")
public ModelAndView toupdatePwd() {
return new ModelAndView("user/modifypwd");
}
@RequestMapping("/login")
public ModelAndView toLogin(User user, HttpSession session, Model model) {
User u = userAuthLocal.getUserByname(user.getName());
... ... @@ -64,7 +69,7 @@ public class UserCtrl {
public ModelAndView updatePwd(String name, String oldpwd, String newpwd, HttpSession session, Model model) {
Object obj = session.getAttribute("user");
String username = String.valueOf(obj);
if ("admin".equals(username)) {
if ("admin".equals(username) && !"admin".equals(name)) {
User user = userAuthLocal.getUserByname(username);
if (user == null) {
model.addAttribute("message", "当前用户不存在");
... ... @@ -73,7 +78,7 @@ public class UserCtrl {
user.setPwd(MD5Util.encryption(newpwd));
httpRestClient.defaultPost(HttpUriContants.USER_UPDATE_PWD, user, BaseResponse.class);
userAuthLocal.flushUser(name);
return new ModelAndView("dashboard/toDashboard");
return new ModelAndView("dashboard/dashBoard");
} else if (name.equals(username)) {
User user = userAuthLocal.getUserByname(username);
... ...
... ... @@ -3,7 +3,7 @@
var innerHTML = "<h5 style='color: #E0EEE0;font-style:oblique;font-weight:900;font-size:200%;margin-left: 45px;margin-top: 20px;'>YOHO</h5>";
innerHTML += "<div id='user-nav'>";
innerHTML += "<ul class='nav btn-group'>";
innerHTML += "<li class='btn btn-inverse'><a href='#'><i class='icon icon-cog'></i> <span class='text'>Settings</span></a></li>";
innerHTML += "<li class='btn btn-inverse'><a id='changepwd_a' href='#'><i class='icon icon-cog'></i> <span class='text'>changePWD</span></a></li>";
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>";
innerHTML += "</ul>";
innerHTML += "</div>";
... ... @@ -49,6 +49,7 @@ document.getElementById("li_nginxview_a").setAttribute("href", path + "/nginx/to
document.getElementById("li_projectRelease_a").setAttribute("href", path + "/project/toProject");
document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toDashboard");
document.getElementById("logout_a").setAttribute("href", path + "/user/logout");
document.getElementById("changepwd_a").setAttribute("href", path + "/user/toupdatePwd");
document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toOthers");
document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList");
document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser");
... ...