From 544c791ddc78de9e8ca96dcc6a13c5da5714d525 Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 4 Dec 2002 09:21:40 +0000 Subject: [PATCH] - moved key-generation from a global function to root/makekey.hac - added a nice feedback skin --- Global/functions.js | 44 +---------------------------------------- Global/pwdfeedback.skin | 20 +++++++++++++++++++ Root/makekey.hac | 32 ++++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 Global/pwdfeedback.skin diff --git a/Global/functions.js b/Global/functions.js index d56f4731..b7c895e9 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -111,7 +111,7 @@ function checkAuth(appObj) { var adminAccess = root.getProperty("adminAccess"); if (adminAccess==null || adminAccess=="") { - return createAuth(); + res.redirect (root.href ("makekey")); } var uname = req.username; @@ -172,48 +172,6 @@ function forceAuth(realm) { - -/** - * response is either a html form to enter auth data or input from - * html form is saved to server.properties - * access is only allowed if remote host is in the list of friendly - * ip-adresses in server.properties - */ -function createAuth() { - if ( checkAddress()!=true ) { - // double check - return false; - } - var obj = new Object(); - obj.msg = ""; - if (req.data.username!=null && req.data.password!=null) { - // we have input from webform - if ( req.data.username=="" ) - obj.msg += "username can't be left empty!
"; - if ( req.data.password=="" ) - obj.msg += "password can't be left empty!
"; - if ( obj.msg!="" ) { - obj.username = req.data.username; - res.reset(); - renderSkin("pwdform",obj); - return false; - } - var str = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
\n"; - res.write ("
" + str + "
"); - return false; - - } else { - // no input from webform, so print it - res.reset(); - res.data.title = "username & password on " + root.hostname_macro(); - res.data.head = renderSkinAsString("head"); - res.data.body = renderSkinAsString("pwdform",obj); - renderSkin("basic"); - return false; - } -} - - /** * macro-utility: formatting property lists */ diff --git a/Global/pwdfeedback.skin b/Global/pwdfeedback.skin new file mode 100644 index 00000000..f5003a67 --- /dev/null +++ b/Global/pwdfeedback.skin @@ -0,0 +1,20 @@ + + + + + +
+ +Generated username and password for helma's manager:
+ +

Please copy/paste this line into the server.properties file of your +helma installation.

+ +
<% param.propsString %>
+ +

After that proceed to ">the manage console, +enter your credentials and you should be allowed in.

+ +
+ + diff --git a/Root/makekey.hac b/Root/makekey.hac index edcf8857..6eb739fb 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -1,5 +1,33 @@ -if ( checkAuth()==false ) + +if (checkAddress()==false) return; -createAuth(); +var obj = new Object(); +obj.msg = ""; +if (req.data.username!=null && req.data.password!=null) { + + // we have input from webform + if ( req.data.username=="" ) + obj.msg += "username can't be left empty!
"; + if ( req.data.password=="" ) + obj.msg += "password can't be left empty!
"; + if ( obj.msg!="" ) { + obj.username = req.data.username; + res.reset(); + res.data.body = renderSkinAsString ("pwdform",obj); + } else { + // render the md5-string: + obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
\n"; + res.data.body = renderSkinAsString ("pwdfeedback", obj); + } +} else { + + // no input from webform, so print it + res.data.body = renderSkinAsString("pwdform",obj); + +} + +res.data.title = "username & password on " + root.hostname_macro(); +res.data.head = renderSkinAsString("head"); +renderSkin("basic");