merged private server and console to private-cloud

This commit is contained in:
strawmanbobi
2020-01-12 19:15:08 +08:00
parent 15d977ccd6
commit 90f2d17331
176 changed files with 220265 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
/**
* Created by strawmanbobi
* 2016-11-24
*/
require('../mini_poem/configuration/constants');
var Cache = require('../mini_poem/cache/redis.js');
var logger = require('../mini_poem/logging/logger4js').helper;
var Enums = require('../constants/enums');
var ErrorCode = require('../constants/error_code');
var enums = new Enums();
var errorCode = new ErrorCode();
var AdminAuth = function(_cacheHost, _cachePort, _cacheAdmin, _cachePassword) {
this.cache = new Cache(_cacheHost, _cachePort, _cacheAdmin, _cachePassword);
};
AdminAuth.prototype.setAuthInfo = function(id, token, ttl, callback) {
this.cache.set(id, token, ttl, function(setAdminAuthErr, data) {
var error = errorCode.SUCCESS;
if(setAdminAuthErr != errorCode.SUCCESS.code) {
error = errorCode.FAILED;
}
callback(error, data);
});
};
AdminAuth.prototype.validateAuthInfo = function(id, token, callback) {
var error = errorCode.SUCCESS;
this.cache.get(id, false, function(getAdminAuthErr, result) {
if(errorCode.SUCCESS.code != getAdminAuthErr || !result || token != result) {
error = errorCode.AUTHENTICATION_FAILURE;
}
callback(error, result);
});
};
AdminAuth.prototype.getAuthInfo = function(id, callback) {
var error = errorCode.SUCCESS;
this.cache.get(id, false, function(getAdminAuthErr, result) {
if(errorCode.SUCCESS.code != getAdminAuthErr) {
error = errorCode.FAILED;
}
callback(error, result);
});
};
AdminAuth.prototype.deleteAuthInfo = function(id, callback) {
var error = errorCode.SUCCESS;
this.cache.delete(id, function(deleteAdminAuthErr) {
if(deleteAdminAuthErr != errorCode.SUCCESS.code) {
error = errorCode.FAILED;
}
callback(error);
});
};
module.exports = AdminAuth;

View File

@@ -0,0 +1,50 @@
/**
* Created by strawmanbobi
* 2016-12-24 (Xmax eve)
*/
require('../mini_poem//configuration/constants');
var Cache = require('../mini_poem//cache/redis.js');
var logger = require('../mini_poem//logging/logger4js').helper;
var Enums = require('../constants/enums');
var ErrorCode = require('../constants/error_code');
var enums = new Enums();
var errorCode = new ErrorCode();
var TicketPair = function(_cacheHost, _cachePort, _cacheAdmin, _cachePassword) {
this.cache = new Cache(_cacheHost, _cachePort, _cacheAdmin, _cachePassword);
};
TicketPair.prototype.setTicketPair = function(id, ticket, ttl, callback) {
this.cache.set(id, ticket, ttl, function(setTicketPairErr, data) {
var error = errorCode.SUCCESS;
if(setTicketPairErr != errorCode.SUCCESS.code) {
error = errorCode.FAILED;
}
callback(error, data);
});
};
TicketPair.prototype.getTicketPair = function(id, callback) {
var error = errorCode.SUCCESS;
this.cache.get(id, false, function(getTicketPairErr, result) {
if(errorCode.SUCCESS.code != getTicketPairErr) {
error = errorCode.FAILED;
}
callback(error, result);
});
};
TicketPair.prototype.deleteTicketPair = function(id, callback) {
var error = errorCode.SUCCESS;
this.cache.delete(id, function(deleteTicketPairErr) {
if(deleteTicketPairErr != errorCode.SUCCESS.code) {
error = errorCode.FAILED;
}
callback(error);
});
};
module.exports = TicketPair;