* Fixed reference to parent site in Archive

* Fixed _children.filter in Archive
 * Added missing permission checks
 * Modified global defineConstants() method to return the getter function instead of automatically defining it with given argument
 * Added HopObject.macro_macro() method to display userland macro code
 * Removed colorpicker (will be replaced by third-party library)
 * Removed obsolete global constants and functions
 * Overhauled and tested global userland macros like story_macro(), image_macro() etc.
 * Implemented global list_macro() to replace any special listFoobar_macro() methods
 * Moved global autoLogin() method into User prototype
 * Overhauled global randomize_macro()
 * Renamed global evalURL() method to validateUrl() as well as evalEmail() to validateEmail()
 * Re-added accidentally removed subskins to Members.skin
 * Fixed some skin names which were changed recently
 * Remove delete_action() from Membership
 * Fixed foreign key of images collection in Membership
 * Removed global username_macro() and replaced it with appropriate membership macros
 * Moved contents of systemscripts.skin into javascript.skin in Root prototype
 * Removed main_css_action(), main_js_action() and sitecounter_macro() methods from Root
 * Added accessname to sites collection in Root
 * Upgraded jQuery to version 1.2.1
 * Replaced call for global history_macro() with corresponding list_macro() call
 * Renamed "public" collection of Stories prototype to "featured"
 * Moved a lot of styles from Root's style.skin to the one in Site
 * Added comments collection to Site
 * Moved embed.skin as subskin #embed into Site.skin
 * Fixed some minor issues in Story.js (removed check for creator before setting the story's mode)
 * Defined cookie names as constants of User which can be overriden via app.properties userCookie and hashCookie
 * Moved a lot of code into compatibility module
This commit is contained in:
Tobi Schäfer 2007-10-11 23:03:17 +00:00
parent ded7f5fcea
commit df9017ab77
38 changed files with 1154 additions and 1736 deletions

View file

@ -22,10 +22,13 @@
// $URL$
//
defineConstants(User, "getStatus", "blocked", "regular", "trusted",
"privileged");
defineConstants(User, "getScopes", "regular users", "trusted users",
"privileged users");
User.COOKIE = getProperty("userCookie", "antvilleUser");
User.HASHCOOKIE = getProperty("hashCookie", "antvilleHash");
User.getStatus = defineConstants(User, "blocked",
"regular", "trusted", "privileged");
User.getScopes = defineConstants(User, "regular users",
"trusted users", "privileged users");
this.handleMetadata("hash");
this.handleMetadata("salt");
@ -71,10 +74,10 @@ User.prototype.update = function(data) {
salt: session.data.token
});
}
this.map({
url: evalURL(data.url),
email: evalEmail(data.email),
});
if (!(this.email = validateEmail(data.email))) {
throw Error(gettext("Please enter a valid e-mail address"));
}
this.url = validateUrl(data.url);
return this;
};
@ -105,7 +108,7 @@ User.prototype.list_macro = function(param, type) {
memberships.forEach(function(membership) {
var site;
if (site = membership.get("site")) {
site.renderSkin("Site#preview");
site.renderSkin("Site#list");
}
return;
});
@ -169,6 +172,31 @@ User.register = function(data) {
return user;
};
User.autoLogin = function() {
if (session.user) {
return;
}
var name = req.cookies[User.COOKIE];
var hash = req.cookies[User.HASHCOOKIE];
if (!name || !hash) {
return;
}
var user = User.getByName(name);
if (!user) {
return;
}
var ip = req.data.http_remotehost.clip(getProperty("cookieLevel", "4"),
"", "\\.");
if ((user.hash + ip).md5() !== hash) {
return;
}
session.login(user);
user.touch();
res.message = gettext('Welcome to "{0}", {1}. Have fun!',
res.handlers.site.title, user.name);
return;
};
User.login = function(data) {
var user = User.getByName(data.name);
if (!user) {
@ -185,10 +213,10 @@ User.login = function(data) {
}
if (data.remember) {
// Set long running cookies for automatic login
res.setCookie("avUsr", user.name, 365);
res.setCookie(User.COOKIE, user.name, 365);
var ip = req.data.http_remotehost.clip(getProperty("cookieLevel", "4"),
"", "\\.");
res.setCookie("avPw", (user.hash + ip).md5(), 365);
res.setCookie(User.HASHCOOKIE, (user.hash + ip).md5(), 365);
}
user.touch();
session.login(user);
@ -203,7 +231,7 @@ User.require = function(s) {
return false;
};
User.getStatus = function() {
User.getCurrentStatus = function() {
if (session.user) {
return session.user.status;
}