Fix navigation when accessing a page results in ACCESS DENIED, enable frame_load to load new frames

This commit is contained in:
Deon George 2024-01-05 21:34:06 +11:00
parent f111a45826
commit d958cdb09d
2 changed files with 12 additions and 8 deletions

15
main.js
View File

@ -946,7 +946,7 @@ while (bbs.online) {
// If we are editing a specific frame, attempt to load it // If we are editing a specific frame, attempt to load it
if (next_page) { if (next_page) {
// In case we need to fall back. // In case we need to fall back.
var current = so; //var current = so;
so.get(next_page); so.get(next_page);
// If the frame doesnt exist, check that the parent frame exists in case we are creating a new one // If the frame doesnt exist, check that the parent frame exists in case we are creating a new one
@ -960,8 +960,8 @@ while (bbs.online) {
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(so)+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')'); log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(so)+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')');
if (so.page.name.toString() === null) { if (so.page.name.toString() === null) {
so = current; //so = current;
current = undefined; //current = undefined;
// sendbaseline ERR_PAGE // sendbaseline ERR_PAGE
so.baselineSend('ERR_NO_PARENT',false); so.baselineSend('ERR_NO_PARENT',false);
action = mode = null; action = mode = null;
@ -1007,7 +1007,6 @@ while (bbs.online) {
control = []; control = [];
log(LOG_DEBUG,'- ACTION_GOTO: ['+(next_page.toString()+']')); log(LOG_DEBUG,'- ACTION_GOTO: ['+(next_page.toString()+']'));
var current = null;
// For logged in users, we'll see if this is a mail page. // For logged in users, we'll see if this is a mail page.
if (user.number) { if (user.number) {
@ -1087,6 +1086,7 @@ while (bbs.online) {
} }
} }
var current = so.page; // If we dont have access to the page we load, we need to revert
if (next_page !== null) { if (next_page !== null) {
if (! so.get(next_page)) { if (! so.get(next_page)) {
log(LOG_DEBUG,'- Next Page: ['+(next_page.toString()+'] doesnt exist?')); log(LOG_DEBUG,'- Next Page: ['+(next_page.toString()+'] doesnt exist?'));
@ -1101,7 +1101,7 @@ while (bbs.online) {
// If the user has access to the frame // If the user has access to the frame
if (so.page.accessible) { if (so.page.accessible) {
if (so.page.isMember && so.page.type === FRAME_TYPE_LOGIN) { if (so.page.isMember && (so.page.type === FRAME_TYPE_LOGIN)) {
so.baselineSend('ALREADY_MEMBER',false); so.baselineSend('ALREADY_MEMBER',false);
action = mode = null; action = mode = null;
break; break;
@ -1112,10 +1112,13 @@ while (bbs.online) {
so.baselineSend('ACCESS_DENIED',false); so.baselineSend('ACCESS_DENIED',false);
action = mode = null; action = mode = null;
// Reset the current frame to what it was. // Reset the current frame to what it was.
so = current; so.page = current;
current = undefined;
break; break;
} }
current = undefined;
log(LOG_DEBUG,'- ACTION_GOTO: next_page ['+JSON.stringify(next_page)+'] last history ['+JSON.stringify(history[history.length-1])+']'); log(LOG_DEBUG,'- ACTION_GOTO: next_page ['+JSON.stringify(next_page)+'] last history ['+JSON.stringify(history[history.length-1])+']');
// Record our history // Record our history

View File

@ -36,6 +36,7 @@ if (page.get(new PageObject(frame,index))) {
page.import(file,ext); page.import(file,ext);
page.save(); page.save();
} else { } else if (['vtx','tex'].indexOf(ext) !== -1) {
throw new Error('Page '+frame+index+' doesnt exist?'); page.import(file,ext);
page.save();
} }