Initial revision

This commit is contained in:
Robert Gaggl 2001-06-18 08:57:33 +00:00
parent 1ba4e8011b
commit bbfcb3d4f4
104 changed files with 3100 additions and 0 deletions

14
code/MemberMgr/edit.hac Normal file
View file

@ -0,0 +1,14 @@
// check if user has right to edit this comment
this.checkPermissions();
res.skin = "main";
if (req.data.submit == "cancel")
res.redirect(this.__parent__.href());
else if (req.data.submit == "save")
this.updateUser();
res.head = this.__parent__.renderSkinAsString("style");
res.body = this.__parent__.renderSkinAsString("header");
res.body += user.renderSkinAsString("edit");

34
code/MemberMgr/login.hac Normal file
View file

@ -0,0 +1,34 @@
res.skin = "main";
if (req.data.name && req.data.password) {
// check if login is successful
if (user.login(req.data.name, req.data.password)) {
// login successful
user.lastVisit = new Date();
res.message = "Welcome to Antville, " + user.name + "! Have fun!";
if (!user.cache.referer) {
if (user.weblog) {
user.weblog.setParent(root);
res.redirect(user.weblog.href());
} else
res.redirect(root.href());
} else {
var redirectTo = user.cache.referer;
user.cache.referer = null;
res.redirect(redirectTo);
}
} else
res.message = "Login failed! Maybe a typo?";
} else {
if (!res.message)
res.message = "Please enter your login name and password:";
}
if (!user.cache.referer && req.data.http_referer)
user.cache.referer = req.data.http_referer;
res.title = "Anville Member Login";
res.head = this.__parent__.renderSkinAsString("style");
res.body = this.__parent__.renderSkinAsString("header");
res.body += this.renderSkinAsString("login");

View file

@ -0,0 +1,6 @@
<FORM METHOD="POST">
<P><% this.input type="text" name="name" prefix="Username:&nbsp;" %><BR>
<% this.input type="password" name="password" prefix="Password:&nbsp;" %><BR>
<% this.input type="button" name="login" value="login!" %></P>
<P>If you're not registered, you can do this <% this.link to="register" text="here" %></P>
</FORM>

11
code/MemberMgr/logout.hac Normal file
View file

@ -0,0 +1,11 @@
if (req.data.http_referer)
var redirectTo = req.data.http_referer;
else if (user.weblog)
var redirectTo = user.weblog.href();
else
var redirectTo = root.href();
res.message = "Good bye, " + user.name + "! Lookin' forward to see you again!";
user.logout();
user.cache.referer = null;
res.redirect(redirectTo);

View file

@ -0,0 +1,84 @@
/**
* check if a registration attempt is ok
*/
function evalRegistration() {
var reg = this.checkReg();
if (!reg.error) {
var newUser = user.register(reg.name, reg.password1);
if (newUser) {
newUser.name = reg.name;
newUser.email = reg.email;
newUser.url = reg.url;
newUser.description = reg.description;
user.login(reg.name, reg.password1);
user.sendConfirmationMail();
res.message = "Welcome " + user.name + ". Have fun!<br>";
res.redirect(root.href());
} else
res.message = "Sorry, we already have a member with that name.";
}
return (reg);
}
/**
* check if all values necessary to register
* are given and return them as properties of a
* temporary HopObject
*/
function checkReg() {
var reg = new HopObject();
if (!res.message) res.message = "Please fill out the form completely and then click the button to register.";
if (req.data.name)
reg.name = req.data.name;
else
reg.error = true;
if (req.data.password1 && req.data.password2) {
if (req.data.password1 == req.data.password2) {
reg.password1 = req.data.password1;
reg.password2 = req.data.password2;
} else {
res.message = "Passwords didn't match! Please re-enter:";
reg.error = true;
}
} else
reg.error = true;
if (req.data.email) {
reg.email = req.data.email;
if (!checkEmail(req.data.email)) {
res.message = "Ooops! The email-address you entered is not valid!";
reg.error = true;
}
} else
reg.error = true;
if (req.data.description)
reg.description = req.data.description;
if (req.data.url)
reg.url = req.data.url;
return (reg);
}
/**
* update user-profile
*/
function updateUser() {
if (req.data.oldpwd && req.data.newpwd1 && req.data.newpwd2) {
if (user.password != req.data.oldpwd) {
res.message = "Old password incorrect!";
res.redirect(this.href("edit"));
} else if (req.data.newpwd1 != req.data.newpwd2) {
res.message = "Ooops! Passwords didn't match! Please type in again!";
res.redirect(this.href("edit"));
} else
user.password = req.data.newpwd1;
}
user.url = req.data.url;
user.email = req.data.email;
user.description = req.data.description;
res.message = "Changes were saved successfully!";
res.redirect(this.__parent__.href());
}

View file

@ -0,0 +1,12 @@
res.skin = "main";
if (req.data.submit == "cancel")
res.redirect(root.href());
else
var reg = this.evalRegistration();
res.title = "Antville member registration";
res.head = root.renderSkinAsString("style");
res.body = root.renderSkinAsString("header");
res.body += this.renderSkinAsString("register",reg);

View file

@ -0,0 +1,11 @@
<FORM METHOD="POST">
<P>Username:&nbsp;<% this.input type="text" name="name" %></P>
Your Password:&nbsp;<% this.input type="password" name="password1" %><BR>
type again:&nbsp;<% this.input type="password" name="password2" %><BR>
Email:&nbsp;<% this.input type="text" name="email" %><BR>
URL:&nbsp;<% this.input type="text" name="url" %><BR>
Description:&nbsp;<% this.input type="textarea" name="description" %><BR>
<% this.input type="button" value="register" %>&nbsp;<% this.input type="button" value="cancel" %>
</FORM>

View file

@ -0,0 +1,11 @@
/**
* function checks if user is allowed to edit her/his profile
*/
function checkPermissions() {
if (!user.uid) {
res.message = "Please login before editing your profile!";
user.cache.referer = this.href("edit");
res.redirect(this.href("login"));
}
}

View file

@ -0,0 +1 @@
<FONT SIZE="-1">Logged in as <% currentUser.name %> ... <% this.link to="edit" text="edit your profile" %> or <% this.link to="logout" text="logout" %></FONT>

View file

@ -0,0 +1 @@
<FONT SIZE="-1">You're not logged in ... <% this.link to="login" text="login" %></FONT>