Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 21b6a08

Browse files
用户修改
1 parent 15ba6ac commit 21b6a08

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

‎src/main/java/com/study/controller/UserController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.study.model.UserRole;
66
import com.study.service.UserRoleService;
77
import com.study.service.UserService;
8+
import com.study.util.PasswordHelper;
89
import org.springframework.util.StringUtils;
910
import org.springframework.web.bind.annotation.RequestMapping;
1011
import org.springframework.web.bind.annotation.RequestParam;
@@ -65,6 +66,9 @@ public String add(User user) {
6566
if(u != null)
6667
return "error";
6768
try {
69+
user.setEnable(1);
70+
PasswordHelper passwordHelper = new PasswordHelper();
71+
passwordHelper.encryptPassword(user);
6872
userService.save(user);
6973
return "success";
7074
} catch (Exception e) {

‎src/main/java/com/study/util/PasswordHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import org.apache.shiro.util.ByteSource;
99

1010
public class PasswordHelper {
11-
private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
11+
//private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
1212
private String algorithmName = "md5";
1313
private int hashIterations = 2;
1414

1515
public void encryptPassword(User user) {
16-
String salt=randomNumberGenerator.nextBytes().toHex();
16+
//String salt=randomNumberGenerator.nextBytes().toHex();
1717
String newPassword = new SimpleHash(algorithmName, user.getPassword(), ByteSource.Util.bytes(user.getUsername()), hashIterations).toHex();
1818
user.setPassword(newPassword);
1919
}

‎src/main/resources/templates/user/users.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,9 @@ <h4 class="modal-title" id="addroleLabel">添加用户</h4>
302302
$.ajax({
303303
cache: true,
304304
type: "POST",
305-
url:'users/add.do',
305+
url:'users/add',
306306
data:$('#userForm').serialize(),// 你的formid
307307
async: false,
308-
dataType:"json",
309308
success: function(data) {
310309
if(data=="success"){
311310
layer.msg('保存成功');
@@ -329,7 +328,7 @@ <h4 class="modal-title" id="addroleLabel">添加用户</h4>
329328
$.ajax({
330329
cache: true,
331330
type: "POST",
332-
url:'${ss}/user/delUser.do',
331+
url:'${ss}/user/delUser',
333332
data:{id:id},
334333
async: false,
335334
dataType:"json",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /