Put SQRL configuration into ini, better trap failed init
This commit is contained in:
parent
38a88eb7c0
commit
cdb0519c49
@ -4,6 +4,10 @@
|
|||||||
;gpg_key=0@videotex
|
;gpg_key=0@videotex
|
||||||
|
|
||||||
; The prefix configurations need to be kept in sync with other nodes
|
; The prefix configurations need to be kept in sync with other nodes
|
||||||
|
[sqrl]
|
||||||
|
auth_url=http://ansitex.bbs.leenooks.net
|
||||||
|
auth_path=sqrl/login
|
||||||
|
auth_post=api/sqrl
|
||||||
|
|
||||||
; Frames with no specific owner are owned by this key
|
; Frames with no specific owner are owned by this key
|
||||||
[prefix]
|
[prefix]
|
||||||
|
@ -117,7 +117,7 @@ function getPageOwners() {
|
|||||||
if (! pageowners.length) {
|
if (! pageowners.length) {
|
||||||
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
|
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
|
||||||
|
|
||||||
if (f.open("r")) {
|
if (f.open('r')) {
|
||||||
var logoans = f.iniGetValue('prefix','logoans');
|
var logoans = f.iniGetValue('prefix','logoans');
|
||||||
var logovtx = f.iniGetValue('prefix','logovtx');
|
var logovtx = f.iniGetValue('prefix','logovtx');
|
||||||
var users = f.iniGetValue('prefix','user');
|
var users = f.iniGetValue('prefix','user');
|
||||||
@ -145,16 +145,16 @@ function getPageOwners() {
|
|||||||
return pageowners;
|
return pageowners;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadOptions() {
|
function loadOptions(option) {
|
||||||
ini = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
|
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
|
||||||
|
|
||||||
if (!ini.open("r")) {
|
if (! f.open('r')) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = ini.iniGetObject(null);
|
val = f.iniGetObject(option);
|
||||||
|
|
||||||
ini.close();
|
f.close();
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,10 @@ function sqrllogin() {
|
|||||||
page.open();
|
page.open();
|
||||||
page.cycle();
|
page.cycle();
|
||||||
|
|
||||||
|
log(LOG_DEBUG,'OPTIONS: '+JSON.stringify(loadOptions('sqrl')));
|
||||||
|
sqrl = loadOptions('sqrl');
|
||||||
http = new HTTPRequest();
|
http = new HTTPRequest();
|
||||||
http.SetupGet('/sqrl/login',undefined,'http://ansitex.leenooks.net');
|
http.SetupGet(sqrl.auth_path,undefined,sqrl.auth_url);
|
||||||
http.request_headers.push('Accept: application/json');
|
http.request_headers.push('Accept: application/json');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -39,15 +41,10 @@ function sqrllogin() {
|
|||||||
http.ReadResponse();
|
http.ReadResponse();
|
||||||
log(LOG_INFO,'SQRL: '+JSON.stringify(http.body));
|
log(LOG_INFO,'SQRL: '+JSON.stringify(http.body));
|
||||||
|
|
||||||
} catch(err) {
|
|
||||||
log(LOG_INFO, "http error: " + err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = http.body
|
var data = http.body
|
||||||
.split('')
|
.split('')
|
||||||
.map(function(x) {return x.charCodeAt(0)});
|
.map(function(x) {return x.charCodeAt(0)});
|
||||||
var qr = qrcodegen.QrCode.encodeBinary(data, qrcodegen.QrCode.Ecc.LOW);
|
var qr = qrcodegen.QrCode.encodeBinary(data,qrcodegen.QrCode.Ecc.LOW);
|
||||||
|
|
||||||
// SMALL Image
|
// SMALL Image
|
||||||
var full = ascii(0xdb);
|
var full = ascii(0xdb);
|
||||||
@ -107,7 +104,7 @@ function sqrllogin() {
|
|||||||
cancel = true;
|
cancel = true;
|
||||||
|
|
||||||
http = new HTTPRequest();
|
http = new HTTPRequest();
|
||||||
http.SetupGet('/api/sqrl?'+nut,undefined,'http://ansitex.leenooks.net');
|
http.SetupGet(sqrl.auth_post+'?'+nut,undefined,sqrl.auth_url);
|
||||||
http.request_headers.push('Accept: application/json');
|
http.request_headers.push('Accept: application/json');
|
||||||
|
|
||||||
log(LOG_DEBUG,'Checking NUT in ['+nut+']');
|
log(LOG_DEBUG,'Checking NUT in ['+nut+']');
|
||||||
@ -133,8 +130,15 @@ function sqrllogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch(err) {
|
||||||
|
log(LOG_INFO,'SQRL Error: '+err);
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
complete = true;
|
complete = true;
|
||||||
|
log(LOG_INFO,'DEBUG: ' + typeof subframe);
|
||||||
|
if (typeof subframe !== 'undefined')
|
||||||
subframe.close();
|
subframe.close();
|
||||||
page.close();
|
page.close();
|
||||||
action = ACTION_GOTO;
|
action = ACTION_GOTO;
|
||||||
|
Loading…
Reference in New Issue
Block a user