Пример #1
0
app.get('/member',function(req, res) {
  var ipAddress = encryption.getIpAddress(req);

  var admin = AV.Object.extend("AdminTable");
  var query = new AV.Query(admin);
  query.equalTo("username","kuro");
  query.greaterThan("password", "123456");

  var user = new AV.User();
  user.set("username","kuro");
  user.set("password","123456");

  query.find({
    success: function(result) {
        user.logIn({
          success: function(user) {
            var logTime = new Date();
            loginMethod = "l成功! 1 " + logTime;
          },
          error: function(user, error) {
            user.signUp(null, {
              success: function(user) {
                user.set("username","kuro");
                user.set("password","123456");
                user.logIn({
                  success: function(user) {
                    loginMethod = "l成功! 2";
                  },
                  error: function(user, error) {
                    loginMethod = error.message;
                  }
                });
              },
              error: function(user,error)
              {}
            });
          }
        });
    },
    error: function(error) {
        user.signUp(null, {
        success: function(user) {
          loginMethod = "s成功! 4";
        },
        error: function(user, error) {
          loginMethod = "s失败! 2";
        }
        });
    }
  });

  //var session = encryption.usersession();

  var info = "2 : " + session.username() + " | " + session.password();

  res.render('index', {
    message: info,
    title: loginMethod
  });

});
Пример #2
0
// //var ad = adminQry.first();
// //var ak = ad.username;

// var tm = [{name: 'aaa',sex: false,age: 20},{name: 'bbb',sex: true,age: 21},{name: 'ccc',sex: false,age: 22}];

// //var al = adminT.chLogin("fishw","123456");
// var chl = "123";
// if(true)
// {
//   chl = "caocao";
// }
// else
// {
//   chl = "caocaocaocao";
// }
var session = encryption.usersession();
// 使用 Express 路由 API 服务 /hello 的 HTTP GET 请求
app.get('/hello', function(req, res) {
  session.username("kuro");
  session.password("123456");

  var user = new AV.User();
  user.set("objectId","544b2f23e4b0e9dff2d02b91");
  user.set("testfeid","fucker");
  user.set("username","kuro");
  user.set("password","123456");
  user.save();

  var info = "1 : " + session.username() + " | " + session.password();
  res.render('hello', 
  {