updated admin login and password change functionality

This commit is contained in:
strawmanbobi
2016-12-07 21:35:14 +08:00
parent 76a5a8155d
commit c296f5e53b

View File

@@ -39,7 +39,9 @@ exports.adminLoginWorkUnit = function (userName, password, callback) {
requestSender.sendPostRequest(signinInfo, requestSender.sendPostRequest(signinInfo,
function(signInRequestErr, signInResponse) { function(signInRequestErr, signInResponse) {
if (signInRequestErr == errorCode.SUCCESS.code && null != signInResponse) { if (signInRequestErr == errorCode.SUCCESS.code && null != signInResponse) {
var admin = JSON.parse(signInResponse).entity; var resp = JSON.parse(signInResponse);
if (undefined != resp.entity) {
var admin = resp.entity;
var userID, var userID,
token, token,
key, key,
@@ -53,6 +55,10 @@ exports.adminLoginWorkUnit = function (userName, password, callback) {
admin.token = token; admin.token = token;
callback(setAdminAuthErr, admin); callback(setAdminAuthErr, admin);
}); });
} else {
callback(errorCode.FAILED, null);
}
} else { } else {
logger.error("admin sign in failed"); logger.error("admin sign in failed");
callback(errorCode.FAILED, null); callback(errorCode.FAILED, null);
@@ -107,10 +113,15 @@ exports.sendChangePwMailWorkUnit = function (userName, callback) {
requestSender.sendPostRequest(userInfo, requestSender.sendPostRequest(userInfo,
function(changePwRequestErr, changePwResponse) { function(changePwRequestErr, changePwResponse) {
if (changePwRequestErr == errorCode.SUCCESS.code && null != changePwResponse) { if (changePwRequestErr == errorCode.SUCCESS.code && null != changePwResponse) {
var resp = JSON.parse(changePwResponse);
if (undefined != resp.status && errorCode.SUCCESS == resp.status) {
callback(errorCode.SUCCESS); callback(errorCode.SUCCESS);
} else { } else {
callback(errorCode.FAILED); callback(errorCode.FAILED);
} }
} else {
callback(errorCode.FAILED);
}
}); });
}; };