-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
272 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/ramostear/unaboot/web/admin/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.ramostear.unaboot.web.admin; | ||
|
||
import com.ramostear.unaboot.common.exception.UnaException; | ||
import com.ramostear.unaboot.service.UserService; | ||
import com.ramostear.unaboot.web.UnaController; | ||
import org.apache.shiro.SecurityUtils; | ||
import org.apache.shiro.authz.annotation.RequiresUser; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* Created by Ramostear on 2019/11/26 0026. | ||
*/ | ||
@Controller | ||
@RequestMapping("/admin/user") | ||
@RequiresUser | ||
public class UserController extends UnaController { | ||
|
||
|
||
@Autowired | ||
private UserService userService; | ||
|
||
|
||
@GetMapping("/profile") | ||
public String profile(){ | ||
return "/admin/user/profile"; | ||
} | ||
|
||
@PostMapping("/{userId}/password") | ||
@ResponseBody | ||
public ResponseEntity<Object> updatePassword(@PathVariable("userId")Integer userId, | ||
@RequestParam(name = "oldPassword")String oldPassword, | ||
@RequestParam(name = "newPassword")String newPassword){ | ||
try { | ||
userService.updatePassword(userId,oldPassword,newPassword); | ||
SecurityUtils.getSubject().logout(); | ||
return ok(); | ||
}catch (UnaException ex){ | ||
return badRequest(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Tags</title> | ||
<link rel="stylesheet" href="${una}/css/bootstrap.css" /> | ||
<link rel="stylesheet" href="${una}/css/font-awesome.css" /> | ||
<link rel="stylesheet" href="${una}/css/ionicons.css" /> | ||
<link rel="stylesheet" href="${una}/js/layer/theme/default/layer.css"/> | ||
<link rel="stylesheet" href="${una}/css/blog-boot.css" /> | ||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-12 p-0"> | ||
<form class="profile-form mt-4"> | ||
<div class="form-group form-inline"> | ||
<span class="col-3 text-right">登录名:</span> | ||
<input class="form-control col-8" value="${profile.username}" readonly="readonly"/> | ||
</div> | ||
<div class="form-group form-inline"> | ||
<span class="col-3 text-right">旧密码:</span> | ||
<input class="form-control col-8" name="oldPassword" type="password"/> | ||
</div> | ||
<div class="form-group form-inline"> | ||
<span class="col-3 text-right">新密码:</span> | ||
<input class="form-control col-8" name="newPassword" type="password"/> | ||
</div> | ||
</form> | ||
<div class="text-center"> | ||
<button type="button" class="btn btn-primary mt-4 ok-btn">确定</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript" src="${una}/js/jquery.min.js" ></script> | ||
<script type="text/javascript" src="${una}/js/bootstrap.min.js" ></script> | ||
<script type="text/javascript" src="${una}/js/bootstrap.bundle.js" ></script> | ||
<script type="text/javascript" src="${una}/js/layer/layer.js"></script> | ||
<script type="text/javascript"> | ||
$(".ok-btn").on("click",function(){ | ||
var oldPassword = $("input[name=oldPassword]").val(); | ||
var newPassword = $("input[name=newPassword]").val(); | ||
if(oldPassword != null && oldPassword.trim()!="" && newPassword!=null && newPassword.trim()!=""){ | ||
$.ajax({ | ||
type:'POST', | ||
url:'${una}/admin/user/${profile.id}/password', | ||
data:{ | ||
oldPassword:oldPassword, | ||
newPassword:newPassword | ||
}, | ||
success:function(){ | ||
parent.location.reload(); | ||
}, | ||
error:function(){ | ||
layer.alert("服务器异常",{title:'系统提示',icon:0}) | ||
} | ||
}); | ||
}else{ | ||
return; | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.