示例#1
0
 private BaasUser getUserByAuth(String appId, String plat, String platform, String uid) {
   BaasQuery query = new BaasQuery();
   query.put("auth." + platform + ".uid", uid);
   List<BaasObject> users =
       objectService.list(appId, plat, USER_CLASS_NAME, query, null, null, 1, 0, null, true);
   if (users.size() == 0) {
     return null;
   }
   return new BaasUser(users.get(0));
 }
示例#2
0
 public void deleteUser(String appId, String plat, String name) {
   BaasQuery query = new BaasQuery();
   query.put("username", name);
   List<BaasObject> users =
       objectService.list(appId, plat, USER_CLASS_NAME, query, null, null, 1, 0, null, true);
   if (users.size() > 0) {
     String sessionToken = users.get(0).getString("sessionToken");
     deleteUserCache(appId, sessionToken);
     objectService.delete(appId, plat, USER_CLASS_NAME, users.get(0).getString("id"), null, true);
   }
 }
示例#3
0
 /**
  * 获取用户
  *
  * @param username 用户名
  * @return 用户
  * @throws SimpleError
  */
 public BaasUser get(
     String appId, String plat, String username, BaasUser currentUser, boolean isMaster) {
   BaasQuery query = new BaasQuery();
   query.put("username", username);
   List<BaasObject> users =
       objectService.list(
           appId, plat, USER_CLASS_NAME, query, null, null, 1, 0, currentUser, isMaster);
   if (users.size() == 0) {
     return null;
   }
   return new BaasUser(users.get(0));
 }
示例#4
0
 public BaasUser getUserBySessionToken(String appId, String plat, String sessionToken) {
   BaasUser userCache = getUserCache(appId, sessionToken);
   if (userCache == null) {
     // 未找到缓存 查询用户数据
     BaasQuery query = new BaasQuery();
     query.put("sessionToken", sessionToken);
     List<BaasObject> users =
         objectService.list(appId, plat, USER_CLASS_NAME, query, null, null, 1, 0, null, true);
     if (users.size() == 0) {
       // 未查询到 sessionToken无效 提示错误
       throw new SimpleError(SimpleCode.USER_SESSION_TOKEN_ERROR);
     }
     BaasUser user = new BaasUser(users.get(0));
     setUserCache(appId, sessionToken, user);
     return user;
   } else {
     return userCache;
   }
 }