- moved key-generation from a global function to root/makekey.hac
- added a nice feedback skin
This commit is contained in:
parent
1f9846f157
commit
544c791ddc
3 changed files with 51 additions and 45 deletions
|
@ -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!<br>";
|
||||
if ( req.data.password=="" )
|
||||
obj.msg += "password can't be left empty!<br>";
|
||||
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) + "<br>\n";
|
||||
res.write ("<pre>" + str + "</pre>");
|
||||
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
|
||||
*/
|
||||
|
|
20
Global/pwdfeedback.skin
Normal file
20
Global/pwdfeedback.skin
Normal file
|
@ -0,0 +1,20 @@
|
|||
<body bgcolor="white">
|
||||
|
||||
<table width="500" border="0" cellspacing="0" cellpadding="5" bgcolor="#000000">
|
||||
<tr>
|
||||
<td width="500" align="left" valign="top" bgcolor="#ffffff">
|
||||
|
||||
<big>Generated username and password for helma's manager:</big><br>
|
||||
|
||||
<p>Please copy/paste this line into the server.properties file of your
|
||||
helma installation.</p>
|
||||
|
||||
<pre><% param.propsString %></pre>
|
||||
|
||||
<p>After that proceed to <a href="<% root.href action="main" %>">the manage console</a>,
|
||||
enter your credentials and you should be allowed in.</p>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</body>
|
|
@ -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!<br>";
|
||||
if ( req.data.password=="" )
|
||||
obj.msg += "password can't be left empty!<br>";
|
||||
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) + "<br>\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");
|
||||
|
|
Loading…
Add table
Reference in a new issue