Numerous minor fixes needed for echomail control, register control. Revert our page object, if the requested page doesnt exist. Rework default pages.
This commit is contained in:
@@ -17,16 +17,15 @@ var CONTROL_ECHOMAIL = '1';
|
||||
log(LOG_DEBUG,'+ Control ECHOMAIL loaded');
|
||||
|
||||
// A unique method name (same as the control name that is called as new method() on initialisation
|
||||
function echomail(pagenum,session) {
|
||||
function echomail(session,pagenum) {
|
||||
log(LOG_DEBUG,' - Loading echomail page:'+pagenum);
|
||||
|
||||
// has this control completed
|
||||
var complete = false;
|
||||
|
||||
var ready = false;
|
||||
|
||||
function init(pagenum,session) {
|
||||
log(LOG_DEBUG,'- init()');
|
||||
function init(session,pagenum) {
|
||||
log(LOG_DEBUG,' - Echomail init('+pagenum+')');
|
||||
|
||||
ready = session.loadMessage(pagenum);
|
||||
}
|
||||
@@ -59,7 +58,7 @@ function echomail(pagenum,session) {
|
||||
break;
|
||||
}
|
||||
|
||||
so.render();
|
||||
session.render();
|
||||
|
||||
return read;
|
||||
}
|
||||
@@ -75,6 +74,7 @@ function echomail(pagenum,session) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
this.ready = function() {
|
||||
log(LOG_DEBUG,'echomail:ready = '+JSON.stringify(ready));
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
@@ -8,11 +8,15 @@ load('graphic.js');
|
||||
|
||||
var CONTROL_FRAMEEDIT = '1';
|
||||
|
||||
function edit(fo) {
|
||||
function edit(session) {
|
||||
log(LOG_DEBUG,'+ Control EDIT loaded');
|
||||
var complete = false;
|
||||
var inProperty = false;
|
||||
|
||||
function init(session) {
|
||||
log(LOG_DEBUG,' - Edit init()');
|
||||
}
|
||||
|
||||
Object.defineProperty(this,'getName', {
|
||||
get: function() {
|
||||
return 'Frame Edit';
|
||||
@@ -148,6 +152,6 @@ function edit(fo) {
|
||||
save();
|
||||
onexit();
|
||||
}
|
||||
}
|
||||
|
||||
this;
|
||||
init.apply(this,arguments);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This handles user registration.
|
||||
*
|
||||
* The form must have the following fields:
|
||||
* + UID The user's user id to login
|
||||
* + USER The user's user id to login
|
||||
* + EMAIL The users's email address - to receive tokens
|
||||
* + FULLNAME The user's full name
|
||||
* + PASS The users's preferred password
|
||||
@@ -17,10 +17,16 @@ var cValChars='ACDEFHJKLMNPQRTUVWXY23456789!@$%&';
|
||||
|
||||
log(LOG_DEBUG,'+ Control REGISTER loaded');
|
||||
|
||||
function register() {
|
||||
function register(session) {
|
||||
var code = '';
|
||||
var complete = false;
|
||||
var processed = false;
|
||||
var ready = false;
|
||||
|
||||
function init(session) {
|
||||
log(LOG_DEBUG,' - Register init()');
|
||||
ready = true;
|
||||
}
|
||||
|
||||
// Called before processing for a field
|
||||
Object.defineProperty(this, 'getName', {
|
||||
@@ -35,11 +41,11 @@ function register() {
|
||||
}
|
||||
});
|
||||
|
||||
this.handle=function(read) {
|
||||
this.handle = function(read) {
|
||||
// Dont allow existing users to re-register
|
||||
if (user.number) {
|
||||
fo.baselineSend('ALREADY_MEMBER',false);
|
||||
return read === '*' ? read : '';
|
||||
session.baselineSend('ALREADY_MEMBER',false);
|
||||
return (read === '*') ? read : '';
|
||||
}
|
||||
|
||||
log(LOG_DEBUG,'Control REGISTER handle() start. ('+read+')');
|
||||
@@ -55,9 +61,9 @@ function register() {
|
||||
complete = true;
|
||||
|
||||
} else {
|
||||
fo.baselineSend('INVALID_CODE',false);
|
||||
fo.cursorOn(cf.c+cf.value.length,cf.r);
|
||||
fo.attr(cf.attribute);
|
||||
session.baselineSend('INVALID_CODE',false);
|
||||
session.cursorOn(cf.c+cf.value.length,cf.r);
|
||||
session.attr(cf.attribute);
|
||||
read = '';
|
||||
}
|
||||
}
|
||||
@@ -67,31 +73,31 @@ function register() {
|
||||
return read;
|
||||
}
|
||||
|
||||
// Make sure we got an email
|
||||
this.prefield=function() {
|
||||
this.prefield = function() {
|
||||
log(LOG_DEBUG,'- prefield: Field '+cf.name+'('+JSON.stringify(cf)+')');
|
||||
|
||||
// Make sure we got an email
|
||||
if (cf.name === 'TOKEN') {
|
||||
if (! code.length) {
|
||||
log(LOG_DEBUG,' - BASELINE '+cf.name+'('+JSON.stringify(cf)+')');
|
||||
fo.baselineSend('TOKEN_EMAIL',false);
|
||||
session.baselineSend('TOKEN_EMAIL',false);
|
||||
|
||||
var email = fo.fieldValue('EMAIL');
|
||||
var uid = fo.fieldValue('UID');
|
||||
var name = fo.fieldValue('FULLNAME');
|
||||
var email = session.fieldValue('EMAIL');
|
||||
var uid = session.fieldValue('USER');
|
||||
var name = session.fieldValue('FULLNAME');
|
||||
|
||||
log(LOG_DEBUG,' - VALIDATE EMAIL TO ('+JSON.stringify(system.matchuserdata(U_NETMAIL,email))+')');
|
||||
|
||||
// Validate Email hasnt been used
|
||||
// Validate USER_ID hasnt been used
|
||||
if ((email.indexOf('@') === -1) || ! EMAIL_REGEX.test(email) || (system.matchuserdata(U_NETMAIL,email) !== 0)) {
|
||||
fo.baselineSend('INVALID_EMAIL',false);
|
||||
session.baselineSend('INVALID_EMAIL',false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! system.check_name(uid)) {
|
||||
log(LOG_DEBUG,' - Cannot use user_id: ('+uid+')');
|
||||
fo.baselineSend('INVALID_UID',false);
|
||||
session.baselineSend('INVALID_UID',false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,18 +107,20 @@ function register() {
|
||||
}
|
||||
|
||||
var hdrs = new Object();
|
||||
hdrs.to=name;
|
||||
hdrs.to_net_type=netaddr_type(email);
|
||||
hdrs.to = name;
|
||||
hdrs.to_net_type = netaddr_type(email);
|
||||
|
||||
if (hdrs.to_net_type !== NET_NONE) {
|
||||
hdrs.to_net_addr = email;
|
||||
} else {
|
||||
fo.baselineSend('CANNOT_SEND_TOKEN',false);
|
||||
session.baselineSend('CANNOT_SEND_TOKEN',false);
|
||||
return;
|
||||
}
|
||||
hdrs.from=system.name;
|
||||
hdrs.from_net_addr='sysop@'+system.inet_addr;
|
||||
hdrs.from_net_type=NET_INTERNET;
|
||||
hdrs.subject='Registration TOKEN for '+system.name;
|
||||
|
||||
hdrs.from = system.name;
|
||||
hdrs.from_net_addr = 'sysop@'+system.inet_addr;
|
||||
hdrs.from_net_type = NET_INTERNET;
|
||||
hdrs.subject = 'Registration TOKEN for '+system.name;
|
||||
|
||||
if (msgbase.open !== undefined && msgbase.open() === false) {
|
||||
console.print("\r\n\1n\1h\1rERROR: \1y" + msgbase.last_error + "\1n \r\n");
|
||||
@@ -137,19 +145,19 @@ function register() {
|
||||
msgbase.close();
|
||||
}
|
||||
|
||||
fo.baselineSend('TOKEN_SENT',false);
|
||||
session.baselineSend('TOKEN_SENT',false);
|
||||
log(LOG_DEBUG,'SENT EMAIL TOKEN ('+code+') ['+JSON.stringify(hdrs)+']');
|
||||
}
|
||||
}
|
||||
|
||||
this.process=function() {
|
||||
log(LOG_DEBUG,'Creating user: '+fo.fieldValue('EMAIL'));
|
||||
this.process = function() {
|
||||
log(LOG_DEBUG,'Creating user: ['+session.fieldValue('EMAIL')+'] ['+session.fieldValue('USER')+']');
|
||||
|
||||
try {
|
||||
var newuser = system.new_user(fo.fieldValue('UID'));
|
||||
var newuser = system.new_user(session.fieldValue('USER'));
|
||||
|
||||
} catch (e) {
|
||||
fo.baselineSend('USER_EXISTS',false);
|
||||
session.baselineSend('USER_EXISTS',false);
|
||||
log(LOG_ERROR,"New user couldn't be created (user created while signing up)");
|
||||
log(LOG_ERROR,JSON.stringify(e));
|
||||
processed = true;
|
||||
@@ -157,7 +165,7 @@ function register() {
|
||||
}
|
||||
|
||||
if (typeof newuser === 'number') {
|
||||
fo.baselineSend('USER_CREATE_ERROR',false);
|
||||
session.baselineSend('USER_CREATE_ERROR',false);
|
||||
log(LOG_ERROR,"New user couldn't be created (error code "+newuser+")");
|
||||
processed = true;
|
||||
return this.isComplete;
|
||||
@@ -166,12 +174,12 @@ function register() {
|
||||
newuser.security.password = '';
|
||||
if (bbs.login(newuser.alias,null)) {
|
||||
user.number = newuser.number;
|
||||
user.security.password = fo.fieldValue('PASS');
|
||||
user.name = fo.fieldValue('FULLNAME');
|
||||
user.handle = fo.fieldValue('UID');
|
||||
user.location = fo.fieldValue('CITY')+', '+fo.fieldValue('COUNTRY');
|
||||
user.zipcode = fo.fieldValue('PCODE');
|
||||
user.netmail = fo.fieldValue('EMAIL');
|
||||
user.security.password = session.fieldValue('PASS');
|
||||
user.name = session.fieldValue('FULLNAME');
|
||||
user.handle = session.fieldValue('USER');
|
||||
user.location = session.fieldValue('CITY')+', '+session.fieldValue('COUNTRY');
|
||||
user.zipcode = session.fieldValue('PCODE');
|
||||
user.netmail = session.fieldValue('EMAIL');
|
||||
user.comment = 'ANSItex registered user';
|
||||
bbs.user_sync();
|
||||
bbs.logon();
|
||||
@@ -183,7 +191,7 @@ function register() {
|
||||
return this.isComplete;
|
||||
|
||||
} else {
|
||||
fo.baselineSend('LOGIN_ERROR',false);
|
||||
session.baselineSend('LOGIN_ERROR',false);
|
||||
log(LOG_INFO,"bbs.login() failed");
|
||||
user.comment = 'Initial login failed!';
|
||||
newuser.settings |= USER_DELETED;
|
||||
@@ -193,6 +201,12 @@ function register() {
|
||||
return this.isComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this;
|
||||
// @todo Doesnt appear to be used
|
||||
this.ready = function() {
|
||||
log(LOG_DEBUG,'register:ready = '+JSON.stringify(ready));
|
||||
return ready;
|
||||
}
|
||||
|
||||
init.apply(this,arguments);
|
||||
}
|
||||
|
Reference in New Issue
Block a user