public BaasUser register(String appId, String plat, BaasUser user) { String username = user.getUsername(); String password = user.getPassword(); if (StringUtils.isEmpty(password)) { // 密码禁止为空 throw new SimpleError(SimpleCode.USER_EMPTY_PASSWORD); } if (StringUtils.isEmpty(username)) { // 用户名禁止为空 throw new SimpleError(SimpleCode.USER_EMPTY_USERNAME); } if (!isNameValid(username)) { // 用户名不合法 throw new SimpleError(SimpleCode.USER_INVALID_USERNAME); } BaasUser exist = get(appId, plat, username, null, true); if (exist != null) { // 用户已存在 throw new SimpleError(SimpleCode.USER_ALREADY_EXIST); } user.setPassword(encrypt(username, password)); user.setSessionToken(getSessionToken()); // 禁止设置ACL字段 user.remove("acl"); BaasObject object = objectService.insert(appId, plat, USER_CLASS_NAME, user, null, true); return new BaasUser(object); }