From 259294a3a1f922188075ad6ddad502eca5886b07 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Mon, 05 Feb 2018 15:06:31 +0800
Subject: [PATCH] 旧版登录功能 加密修复
---
src/main/java/com/moral/service/impl/AccountServiceImpl.java | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/moral/service/impl/AccountServiceImpl.java b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
index 83484e0..1da082a 100644
--- a/src/main/java/com/moral/service/impl/AccountServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -7,15 +7,11 @@
import static org.apache.commons.lang3.StringUtils.isNumeric;
import static org.springframework.util.ObjectUtils.isEmpty;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import javax.annotation.Resource;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
@@ -38,7 +34,8 @@
@Service
public class AccountServiceImpl implements AccountService {
-
+ @Resource
+ private BCryptPasswordEncoder encoder;
@Resource
private AccountMapper accountMapper;
@@ -47,13 +44,13 @@
@Resource
private OrganizationMapper organizationMapper;
-
+
@Override
public Map<String, Object> screenLogin(Map<String, Object> parameters) {
Map<String, Object> result = new HashMap<String, Object>();
Account account = new Account();
account.setAccountName((String) parameters.get("account"));
- account.setPassword(md5((String) parameters.get("password")));
+ account.setPassword(encoder.encode((String) parameters.get("password")));
account = accountMapper.selectOne(account);
if (isEmpty(account)) {
result.put("msg", "���������������������������������");
@@ -75,7 +72,10 @@
account.setAccountName(accountName);
return accountMapper.selectOne(account);
}
-
+ @Override
+ public Account getAccountById(Integer id){
+ return accountMapper.selectByPrimaryKey(id);
+ }
@Override
public void setOrgIdsByAccount(Map<String, Object> parameters) {
String accountId = (String) parameters.get("accountId");
@@ -144,7 +144,7 @@
if (ObjectUtils.isEmpty(account.getId())) {
account.setIsDelete(Constants.IS_DELETE_FALSE);
account.setCreateTime(new Date());
- account.setPassword(Crypto.md5(ResourceUtil.getValue("password")));
+ account.setPassword(encoder.encode(ResourceUtil.getValue("password")));
return accountMapper.insertSelective(account);
} else {
return accountMapper.updateByPrimaryKeySelective(account);
@@ -168,4 +168,9 @@
return accountMapper.selectCount(account);
}
+ @Override
+ public Optional<Account> queryAccountByName(String accountName) {
+ Account account = accountMapper.getByAccountName(accountName);
+ return Optional.ofNullable(account);
+ }
}
--
Gitblit v1.8.0