コード例 #1
0
 @Aop("redis")
 public String accessToken(UserProfile profile) {
   String loginname = profile.getLoginname();
   String at = jedis().hget(RKEY_USER_ACCESSTOKEN, loginname);
   if (at == null) {
     // 双向绑定
     at = R.UU32();
     jedis().hset(RKEY_USER_ACCESSTOKEN, loginname, at);
     jedis().hset(RKEY_USER_ACCESSTOKEN2, at, loginname);
     jedis().hset(RKEY_USER_ACCESSTOKEN3, at, "" + profile.getUserId());
   }
   return at;
 }
コード例 #2
0
 @OnEvent("get_auth_qr")
 public void getAuthQr(SocketIOClient client, Object data, AckRequest ackRequest) {
   NutMap re = new NutMap();
   try {
     // TODO 可配置
     SeckenResp resp =
         secken
             .getAuth(1, "https://nutz.cn/secken/callback/" + R.UU32(client.getSessionId()))
             .check();
     String url = resp.qrcode_url();
     re.put("ok", true);
     re.put("url", url);
   } catch (Exception e) {
     log.debug("获取洋葱授权二维码识别", e);
     re.put("msg", "获取洋葱授权二维码识别");
   }
   client.sendEvent("new_auth_qr", re);
 }
コード例 #3
0
 public NutMap upload(TempFile tmp, int userId) throws IOException {
   NutMap re = new NutMap();
   if (userId < 1) return re.setv("msg", "请先登陆!");
   if (tmp == null || tmp.getSize() == 0) {
     return re.setv("msg", "空文件");
   }
   if (tmp.getSize() > 10 * 1024 * 1024) {
     tmp.delete();
     return re.setv("msg", "文件太大了");
   }
   String id = R.UU32();
   String path = "/" + id.substring(0, 2) + "/" + id.substring(2);
   File f = new File(imageDir + path);
   Files.createNewFile(f);
   Files.write(f, tmp.getInputStream());
   tmp.delete();
   re.put("url", Mvcs.getServletContext().getContextPath() + "/yvr/upload" + path);
   re.setv("success", true);
   return re;
 }