* Separated the global setup settings from those in the root site's preferences

* Added encoding="form" parameter to most of the macros using the request handler
 * Renamed commentsMode to commentMode (comments_mode to comment_mode in DB)
 * Reactivated notifications in a simplified manner
 * Throw an error in global sendMail() method if arguments are not sufficient
 * Added HopObject.notify() method
 * Added HopObject.kind_macro() method (provides the constructor's name in lowercase)
 * Added Messages.skin containing subskins suited for e-mail output
 * Removed obsolete skin files
 * Added reset_action() method for resetting a user's password to Members prototype
 * Added require() method to Membership prototype; wrapped static require() method around it
 * Added Membership.notify() method which does all the member-related notification stuff
 * Send notification on membership removal
 * Fixed contact form in Membership prototype
 * Dropped e-mail property from Site prototype (users can be contacted via Membership.contact_action(), Root prototype has extra e-mail property)
 * Added missing getPermission() method to User prototype, always requiring a privileged user
This commit is contained in:
Tobi Schäfer 2007-10-15 23:29:03 +00:00
parent 504260650e
commit 3e8c4c6313
34 changed files with 336 additions and 276 deletions

View file

@ -29,8 +29,9 @@ Members.prototype.getPermission = function(action) {
switch (action) {
case "login":
case "logout":
case "salt.js":
case "register":
case "reset":
case "salt.js":
return true;
case ".":
case "main":
@ -74,18 +75,12 @@ Members.prototype.main_action = function() {
Members.prototype.register_action = function() {
if (req.postParams.register) {
try {
var user = User.register(req.postParams);
// Subscribe user to this site if it is public
if (Site.require(Site.PUBLIC)) {
this.add(new Membership(user));
}
var title = res.handlers.site.title;
if (root.sys_email) {
var sp = {name: user.name};
sendMail(root.sys_email, user.email,
gettext('Welcome to "{0}"!', title),
this.renderSkinAsString("mailregconfirm", sp));
}
var user = User.register(req.postParams);
var membership = new Membership(user);
this.add(membership);
membership.notify(req.action, user.email,
gettext('Welcome to "{0}"!', title));
var url = session.data.referrer || this._parent.href();
delete session.data.referrer;
res.message = gettext('Welcome to "{0}", {1}. Have fun!',
@ -105,6 +100,36 @@ Members.prototype.register_action = function() {
return;
};
Members.prototype.reset_action = function() {
if (req.postParams.reset) {
try {
if (!req.postParams.name || !req.postParams.email) {
throw Error(gettext("Please enter username and e-mail of the desired account."));
}
var user = User.getByName(req.postParams.name);
if (!user || user.email !== req.postParams.email) {
throw Error(gettext("Username and e-mail do not match."))
}
var password = jala.util.createPassword(25, 2);
user.hash = (password + user.salt).md5()
sendMail(root.email, user.email,
gettext("Your login at {0}", this._parent.title),
user.renderSkinAsString("Messages#reset",
{password: password}));
res.message = "A new password is sent to the account's e-mail address.";
res.redirect(this._parent.href());
} catch(ex) {
app.log(ex);
res.message = ex;
}
}
res.data.action = this.href(req.action);
res.data.title = gettext("Reset password");
res.data.body = this.renderSkinAsString("Members#reset");
this._parent.renderSkin("page");
return;
};
Members.prototype.login_action = function() {
if (req.postParams.login) {
try {
@ -264,16 +289,10 @@ Members.prototype.add_action = function() {
}
} else if (req.postParams.add) {
try {
res.handlers.sender = User.getMembership();
var membership = this.addMembership(req.postParams);
var message = this.renderSkinAsString("mailnewmember", {
site: res.handlers.site.title,
creator: session.user.name,
url: res.handlers.site.href(),
account: req.postParams.name
});
// FIXME:
//sendMail(root.sys_email, result.obj.user.email,
// getMessage("mail.newMember", result.obj.site.title), message);
membership.notify(req.action, membership.creator.email,
gettext('Notification of membership change', root.title));
res.message = gettext("Successfully added {0} to the list of members.",
req.postParams.name);
res.redirect(membership.href("edit"));

View file

@ -1,6 +1,6 @@
<% #main %>
<div class="ample">
<% members.link add "add a member" prefix="...&nbsp;" %>
<% members.link add "add a member" prefix="..." %>
</div>
<% members.link . all prefix="... show " %>
<% members.link owners prefix="| " %>
@ -37,26 +37,26 @@ $(function() {
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="small">Username:</td>
<td nowrap="nowrap">
<td>
<input type="text" name="name" id="name" size="15" tabindex="1"
value="<% request.name %>" />
value="<% request.name encoding="form" %>" />
</td>
<td rowspan="4" nowrap="nowrap"> </td>
<td rowspan="4"> </td>
<td class="small">
<% members.link register "Not registered yet" %>
</td>
</tr>
<tr>
<td class="small" nowrap="nowrap">Password:</td>
<td class="small">Password:</td>
<td>
<input type="password" name="password" id="password" size="15" tabindex="2" />
</td>
<td class="small">
<% members.link sendpwd "Forgot your password?" %>
<% members.link reset "Password forgotten?" %>
</td>
</tr>
<tr>
<td nowrap="nowrap"> </td>
<td> </td>
<td colspan="2" class="small">
<input type="checkbox" id="remember" name="remember" tabindex="3"
<% if <% request.remember %> is "on" then 'checked="checked"' %> />
@ -64,7 +64,7 @@ value="<% request.name %>" />
</td>
</tr>
<tr>
<td nowrap="nowrap"> </td>
<td> </td>
<td colspan="2"><br />
<button type="submit" id="submit" name="login" value="1"
tabindex="4">login</button>
@ -99,32 +99,32 @@ $(function() {
<input type="hidden" name="hash" id="hash" />
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="small" nowrap="nowrap">Username:</td>
<td nowrap="nowrap">
<input type="text" name="name" value="<% request.name %>" />
</td>
</tr>
<tr>
<td class="small" valign="top" nowrap="nowrap">e-mail:</td>
<td class="small">Username:</td>
<td>
<input type="text" name="email" value="<% request.email %>" />
<input type="text" name="name" value="<% request.name encoding="form" %>" />
</td>
</tr>
<tr>
<td class="small" nowrap="nowrap">Password:</td>
<td nowrap="nowrap">
<td class="small" valign="top">e-mail:</td>
<td>
<input type="text" name="email" value="<% request.email encoding="form" %>" />
</td>
</tr>
<tr>
<td class="small">Password:</td>
<td>
<input type="password" name="password" id="password" />
</td>
</tr>
<tr>
<td class="small" nowrap="nowrap">Confirm password:</td>
<td nowrap="nowrap">
<td class="small">Confirm password:</td>
<td>
<input type="password" name="passwordConfirm" id="passwordConfirm" />
</td>
</tr>
<tr>
<td nowrap="nowrap">&nbsp;</td>
<td nowrap="nowrap"><br />
<td></td>
<td><br />
<button type="submit" id="submit" name="register"
value="register">Register</button>
<button type="submit" name="cancel" value="cancel">Cancel</button>
@ -133,14 +133,28 @@ value="register">Register</button>
</table>
</form>
<% #reset %>
<form id="login" method="post" action="<% response.action %>">
<div class="small">Username:</div>
<div><input type="text" name="name" id="name" size="15" tabindex="1"
value="<% request.name encoding="form" %>" /></div>
<div class="small">e-mail:</div>
<div><input type="text" name="email" id="email" size="15" tabindex="2"
value="<% request.email encoding="form" %>"/></div>
<br />
<button type="submit" id="submit" name="reset" value="1"
tabindex="4">reset</button>
</form>
<% #add %>
<form method="post" action="<% response.action %>">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td nowrap="nowrap">
<input type="text" name="term" id="term" value="<% request.term %>" />
<td>
<input type="text" name="term" id="term"
value="<% request.term encoding="form" %>" />
</td>
<td nowrap="nowrap">
<td>
<button type="submit" name="search" value="1">Search</button>
</td>
</tr>

View file

@ -1,7 +0,0 @@
<% param.creator %> has added you (meaning your account "<% param.account %>") to the list of members of <% param.site %> (<% param.url %>).
Have fun!
---------------------------------------
<% root.title %> - <% root.url %>
---------------------------------------

View file

@ -1,9 +0,0 @@
On <% now format="long" %> you requested a list of all your accounts for '<% root.title %>', so here it is:
<% param.text %>
Have fun!
---------------------------------------
<% root.title %> - <% root.url %>
---------------------------------------

View file

@ -1,12 +0,0 @@
Welcome to <% root.title %>!
Here's your login info:
Username: <% param.name %>
Password: <% param.password %>
Have fun!
---------------------------------------
<% root.title %> - <% root.url %>
---------------------------------------

View file

@ -1,14 +0,0 @@
<p>Please enter the e-mail address you most likely used back then when you registered yourself here. An e-mail containing all accounts that were registered with this e-mail address will be sent back to this address.</p>
<form method="post" action="<% response.action %>">
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="small" nowrap="nowrap">e-mail:</td>
<td nowrap="nowrap"><% input type="text" name="email" %></td>
</tr>
<tr>
<td nowrap="nowrap">&nbsp;</td>
<td nowrap="nowrap"><% input type="submit" name="send" value="Send" %>&nbsp;<% input type="submit" name="cancel" value="Cancel" %></td>
</tr>
</table>
</form>