* ButtonView is now MCI BT. BN is pre-defined "Board Name"
* Client current theme info loaded & used for e.g. passwordChar * Code cleanup
This commit is contained in:
@@ -56,6 +56,8 @@ function ApplyModule(menuConfig) {
|
||||
affiliation : args.affils,
|
||||
email_address : args.email,
|
||||
web_address : args.web,
|
||||
art_theme_id : Config.users.defaultTheme, // :TODO: allow '*' = random
|
||||
account_status : user.User.AccountStatus.inactive,
|
||||
|
||||
// :TODO: Other defaults
|
||||
// :TODO: should probably have a place to create defaults/etc.
|
||||
@@ -64,9 +66,15 @@ function ApplyModule(menuConfig) {
|
||||
|
||||
newUser.create({ password : args.pw }, function created(err) {
|
||||
if(err) {
|
||||
console.log(err)
|
||||
self.client.gotoMenuModule( { name : args.next.error } );
|
||||
} else {
|
||||
Log.info( { username : args.username, userId : newUser.userId }, 'New user created');
|
||||
|
||||
if(user.User.AccountStatus.inactive === self.client.user.properties.account_status) {
|
||||
self.client.gotoMenuModule( { name : args.next.inactive } );
|
||||
} else {
|
||||
self.client.gotoMenuModule( { name : args.next.active } );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,6 @@
|
||||
"name" : "Nu Mayan",
|
||||
"author" : "NuSkooler",
|
||||
"config" : {
|
||||
"passwordChar" : "*"
|
||||
"passwordChar" : "φ"
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ var Log = require('../core/logger.js').log;
|
||||
var MenuModule = require('../core/menu_module.js').MenuModule;
|
||||
var ViewController = require('../core/view_controller.js').ViewController;
|
||||
|
||||
//var async = require('async');
|
||||
var async = require('async');
|
||||
|
||||
// :TODO: clean up requires
|
||||
|
||||
@@ -33,6 +33,8 @@ function LoginModule(menuConfig) {
|
||||
this.menuMethods.attemptLogin = function(args) {
|
||||
self.client.user.authenticate(args.username, args.password, function onAuth(err) {
|
||||
if(err) {
|
||||
// :TODO: change to simple login/username prompts - no buttons.
|
||||
|
||||
Log.info( { username : args.username }, 'Failed login attempt %s', err);
|
||||
|
||||
// :TODO: localize:
|
||||
@@ -52,6 +54,20 @@ function LoginModule(menuConfig) {
|
||||
Log.info( { username : self.client.user.username }, 'Successful login');
|
||||
|
||||
// :TODO: persist information about login to user
|
||||
|
||||
async.parallel(
|
||||
[
|
||||
function loadThemeConfig(callback) {
|
||||
theme.getThemeInfo(self.client.user.properties.art_theme_id, function themeInfo(err, info) {
|
||||
self.client.currentThemeInfo = info;
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
],
|
||||
function complete(err, results) {
|
||||
self.client.gotoMenuModule( { name : args.next.success } );
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Some concept/ideas:
|
||||
"mci" : {
|
||||
"BN1" : {
|
||||
"BT1" : {
|
||||
...
|
||||
"draw" : "@script:blah.js/drawButton"
|
||||
// @method:scriptName[.js]/methodName (foreign .js)
|
||||
@@ -16,6 +16,7 @@
|
||||
}
|
||||
|
||||
..note that script/methods should be part of a *theme* - or at least checked first with fallback
|
||||
.....why?
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -60,16 +61,16 @@
|
||||
"module" : "login",
|
||||
"form" : {
|
||||
"0" : {
|
||||
"BN3BN4ET1ET2TL5" :{
|
||||
"BT3BT4ET1ET2TL5" :{
|
||||
"mci" :{
|
||||
"ET1" : {
|
||||
"focus" : true
|
||||
},
|
||||
"BN3" : {
|
||||
"BT3" : {
|
||||
"submit" : true,
|
||||
"text" : "Login"
|
||||
},
|
||||
"BN4" : {
|
||||
"BT4" : {
|
||||
"submit" : true,
|
||||
"text" : "Cancel"
|
||||
}
|
||||
@@ -79,10 +80,16 @@
|
||||
{
|
||||
"value" : { "3" : null },
|
||||
"action" : "@method:attemptLogin",
|
||||
"args" : { "username" : "{1}", "password" : "{2}" } // :TODO: rename to actionArgs ?
|
||||
"args" : {
|
||||
"next" : {
|
||||
"success" : "newUserActive"
|
||||
},
|
||||
"username" : "{1}",
|
||||
"password" : "{2}"
|
||||
} // :TODO: rename to actionArgs ?
|
||||
}
|
||||
],
|
||||
"4" : [ // cancel
|
||||
"4" : [ // Cancel
|
||||
{
|
||||
"value" : { "4" : null },
|
||||
"action" : "@menu:matrix"
|
||||
@@ -105,16 +112,16 @@
|
||||
"module" : "apply",
|
||||
"form" : {
|
||||
"0" : {
|
||||
"BN12BN13ET1ET10ET2ET3ET4ET5ET6ET7ET8ET9TL11" : {
|
||||
"BT12BT13ET1ET10ET2ET3ET4ET5ET6ET7ET8ET9TL11" : {
|
||||
"mci" : {
|
||||
"ET1" : {
|
||||
"focus" : true
|
||||
},
|
||||
"BN12" : {
|
||||
"BT12" : {
|
||||
"submit" : true,
|
||||
"text" : "Apply"
|
||||
},
|
||||
"BN13" : {
|
||||
"BT13" : {
|
||||
"submit" : true,
|
||||
"text" : "Cancel"
|
||||
}
|
||||
@@ -124,10 +131,12 @@
|
||||
{
|
||||
"value" : { "12" : null },
|
||||
"action" : "@method:submitApplication",
|
||||
// :TODO: Need a way to supply next menu based on data from @method
|
||||
// @method:submitApplication|nextMenu1|nextMenu2|nextMenu3 ? method could cb(indexValue)
|
||||
|
||||
"args" : {
|
||||
"next" : {
|
||||
"inactive" : "userNeedsActivated",
|
||||
"active" : "newUserActive",
|
||||
"error" : "newUserCreateError"
|
||||
},
|
||||
"username" : "{1}",
|
||||
"realName" : "{2}",
|
||||
"age" : "{3}",
|
||||
@@ -143,7 +152,7 @@
|
||||
],
|
||||
"13" : [ // Cancel
|
||||
{
|
||||
"value" : { "13" : null },
|
||||
"value" : { "13" : null }, // :TODO: allow just "13" (number)
|
||||
"action" : "@menu:matrix"
|
||||
}
|
||||
]
|
||||
@@ -154,5 +163,20 @@
|
||||
"options" : {
|
||||
"clearScreen" : true
|
||||
}
|
||||
},
|
||||
"newUserActive" : {
|
||||
"art" : "NEWACT",
|
||||
"options" : {
|
||||
"clearScreen" : true
|
||||
},
|
||||
"form" : {
|
||||
"0" : {
|
||||
"UN1UR2" : {
|
||||
"mci" : {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,91 +43,5 @@ StandardMenuModule.prototype.mciReady = function(mciMap) {
|
||||
console.log(formData);
|
||||
});*/
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
menuUtil.getFormConfig(self.menuConfig, mciMap, function onFormConfig(err, formConfig) {
|
||||
console.log(formConfig);
|
||||
var vc = self.addViewController(new ViewController(self.client));
|
||||
vc.loadFromMCIMap(mciMap);
|
||||
vc.setViewOrder();
|
||||
|
||||
Object.keys(formConfig.mci).forEach(function onFormMci(mci) {
|
||||
var viewId = parseInt(mci[2]);
|
||||
if(formConfig.mci[mci].items && formConfig.mci[mci].items.length > 0) {
|
||||
vc.getView(viewId).setItems(formConfig.mci[mci].items);
|
||||
}
|
||||
});
|
||||
|
||||
//vc.getView(1).setItems(['Login', 'New User', 'Goodbye!']);
|
||||
vc.getView(1).submit = true;
|
||||
vc.switchFocus(1);
|
||||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
{
|
||||
"menuName" : {
|
||||
"form" : [
|
||||
{
|
||||
"mciReq" : [ "MC1", "MC2", ... ],
|
||||
"MC1" : {
|
||||
"text" : "...",
|
||||
"focus" : true,
|
||||
"submit" : true,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
if(mciMap.ET1 && mciMap.ET2 && mciMap.BN1 && mciMap.BN2 && mciMap.BN3) {
|
||||
//
|
||||
// Form via EditTextViews and ButtonViews
|
||||
// * ET1 - userName
|
||||
// * ET2 - password
|
||||
// * BN1 - Login
|
||||
// * BN2 - New
|
||||
// * BN3 - Bye!
|
||||
//
|
||||
} else if(mciMap.VM1) {
|
||||
//
|
||||
// Menu via VerticalMenuView
|
||||
//
|
||||
// * VM1 - menu with the following items:
|
||||
// 0 - Login
|
||||
// 1 - New
|
||||
// 2 - Bye!
|
||||
//
|
||||
//var vc = new ViewController(client);
|
||||
var vc = self.addViewController(new ViewController(self.client));
|
||||
|
||||
vc.on('submit', function onSubmit(form) {
|
||||
console.log(form);
|
||||
|
||||
var viewModuleMap = {
|
||||
'0' : 'login',
|
||||
'1' : 'new',
|
||||
'2' : 'logoff',
|
||||
};
|
||||
|
||||
if(0 === form.id && 1 === form.submitId) {
|
||||
console.log(viewModuleMap[form.value[1]]);
|
||||
self.client.gotoMenuModule(viewModuleMap[form.value[1]]);
|
||||
}
|
||||
});
|
||||
|
||||
vc.loadFromMCIMap(mciMap);
|
||||
vc.setViewOrder();
|
||||
// :TODO: Localize
|
||||
vc.getView(1).setItems(['Login', 'New User', 'Goodbye!']);
|
||||
vc.getView(1).submit = true;
|
||||
vc.switchFocus(1);
|
||||
}
|
||||
*/
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user