mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +08:00
登录验证的修改
This commit is contained in:
@@ -28,6 +28,10 @@ public class AccountDao extends BaseDao<Account> {
|
|||||||
return this.findOne(FieldFilters.eq("loginName", loginName), FieldFilters.eq("deleted", false));
|
return this.findOne(FieldFilters.eq("loginName", loginName), FieldFilters.eq("deleted", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Account findLoginBySysId(String sysId) {
|
||||||
|
return this.findOne(FieldFilters.eq("sysId", sysId),FieldFilters.eq("deleted", false));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查账号是否存在
|
* 检查账号是否存在
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ public interface IAccountService {
|
|||||||
*/
|
*/
|
||||||
Account getBySysId(String id);
|
Account getBySysId(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为登录获取用户账号
|
||||||
|
* @param sysId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Account findLoginBySysId(String sysId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按登录名查询账号
|
* 按登录名查询账号
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.xboe.account.service.impl;
|
package com.xboe.account.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -17,7 +18,6 @@ import com.xboe.account.service.IAccountService;
|
|||||||
import com.xboe.common.utils.MD5Util;
|
import com.xboe.common.utils.MD5Util;
|
||||||
import com.xboe.common.utils.StringUtil;
|
import com.xboe.common.utils.StringUtil;
|
||||||
import com.xboe.constants.CacheName;
|
import com.xboe.constants.CacheName;
|
||||||
import com.xboe.core.exception.DaoException;
|
|
||||||
import com.xboe.core.exception.XaskException;
|
import com.xboe.core.exception.XaskException;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
import com.xboe.core.orm.UpdateBuilder;
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
@@ -140,4 +140,30 @@ public class AccountServiceImpl implements IAccountService {
|
|||||||
public void delete(Account account) {
|
public void delete(Account account) {
|
||||||
dao.setDeleted(account.getId());
|
dao.setDeleted(account.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Account findLoginBySysId(String sysId) {
|
||||||
|
|
||||||
|
//重复用户的问题
|
||||||
|
List<Account> list=dao.findList(FieldFilters.eq("sysId", sysId));
|
||||||
|
if(list.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Account account=null;
|
||||||
|
for(Account a:list) {
|
||||||
|
if(!a.getDeleted() && a.getStatus()<Account.STATUS_DEAD) {
|
||||||
|
account=a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(account!=null) {
|
||||||
|
Account result = new Account();
|
||||||
|
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||||
|
return result;
|
||||||
|
}else{
|
||||||
|
account=list.get(0);
|
||||||
|
Account result = new Account();
|
||||||
|
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class PortalLoginApi extends ApiBaseController {
|
|||||||
}else{
|
}else{
|
||||||
// 没有aid则判断是否已同步的用户,不是则同步
|
// 没有aid则判断是否已同步的用户,不是则同步
|
||||||
if(StringUtil.isNotBlank(tokenInfo.get("userId"))){
|
if(StringUtil.isNotBlank(tokenInfo.get("userId"))){
|
||||||
account = accountService.getBySysId(tokenInfo.get("userId"));
|
account = accountService.findLoginBySysId(tokenInfo.get("userId"));
|
||||||
if(account == null){ //系统中无此用户,需要同步用户
|
if(account == null){ //系统中无此用户,需要同步用户
|
||||||
UserVo fwUser = fwUserService.getById(tokenInfo.get("userId"));
|
UserVo fwUser = fwUserService.getById(tokenInfo.get("userId"));
|
||||||
if(fwUser != null) {
|
if(fwUser != null) {
|
||||||
@@ -221,6 +221,12 @@ public class PortalLoginApi extends ApiBaseController {
|
|||||||
log.error("boelogin同步用户错误:" + e.getMessage());
|
log.error("boelogin同步用户错误:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
if(account.getDeleted()) {
|
||||||
|
return error("登录失败,用户已被删除,请与管理员联系");
|
||||||
|
}else if(account.getStatus()==Account.STATUS_DEAD) {
|
||||||
|
return error("登录失败,用户已被停用,请与管理员联系");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
return error("token不合法");
|
return error("token不合法");
|
||||||
|
|||||||
Reference in New Issue
Block a user