public static MerchantUser findByLoginNamePasswordAndLinkId( String userName, String password, String linkId) { if (StringUtils.isBlank(password)) { Logger.info("传入密码为空,登录失败"); return null; } MerchantUser user = MerchantUser.find("loginName=? and merchant.linkId=? order by id", userName, linkId) .first(); if (user == null) { Logger.info("找不到指定用户名(%s)对应的商户操作员.", userName); return null; } return user; }
/** * 使用密码登录. * * @param userName * @param password * @return 是否登录成功. */ public static Boolean login(String userName, String password) { if (StringUtils.isBlank(password)) { Logger.info("传入密码为空,登录失败"); return false; } MerchantUser user = MerchantUser.find("loginName=? or mobile=? order by id", userName, userName).first(); if (user == null) { Logger.info("找不到指定用户名(%s)对应的商户操作员.", userName); return false; } String hashPassword = DigestUtils.md5Hex(password + user.passwordSalt); if (!hashPassword.equals(user.encryptedPassword)) { Logger.info( "密码不匹配,user.encryptedPassword=%s, hashPassword=%s", user.encryptedPassword, hashPassword); return false; } return true; }
public static MerchantUser findByLoginNameAndPassword(String userName, String password) { if (StringUtils.isBlank(password)) { Logger.info("传入密码为空,登录失败"); return null; } MerchantUser user = MerchantUser.find("loginName=? or mobile=? order by id", userName, userName).first(); if (user == null) { Logger.info("找不到指定用户名(%s)对应的商户操作员.", userName); return null; } // TODO 暂时屏蔽掉密码 // String hashPassword = DigestUtils.md5Hex(password + user.passwordSalt); // if (!hashPassword.equals(user.encryptedPassword)) { // Logger.info("密码不匹配,user.encryptedPassword=%s, hashPassword=%s", // user.encryptedPassword, hashPassword); // return null; // } return user; }