Sourcecode in MemberMgr/objectFunctions.js:
1: function evalRegistration(param) {
2: // check if username is existing and is clean
3: // can't use isClean() here because we accept
4: // special characters like umlauts and spaces
5: var invalidChar = new RegExp("[^a-zA-Z0-9äöüß\\.\\-_ ]");
6: if (!param.name)
7: throw new Exception("usernameMissing");
8: else if (param.name.length > 30)
9: throw new Exception("usernameTooLong");
10: else if (invalidChar.exec(param.name))
11: throw new Exception("usernameNoSpecialChars");
12: else if (this[param.name] || this[param.name + "_action"])
13: throw new Exception("usernameExisting");
14:
15: // check if passwords match
16: if (!param.password1 || !param.password2)
17: throw new Exception("passwordTwice");
18: else if (param.password1 != param.password2)
19: throw new Exception("passwordNoMatch");
20:
21: // check if email-address is valid
22: if (!param.email)
23: throw new Exception("emailMissing");
24: evalEmail(param.email);
25:
26: var newUser = app.registerUser(param.name, param.password1);
27: if (!newUser)
28: throw new Exception("memberExisting");
29: newUser.email = param.email;
30: newUser.publishemail = param.publishemail;
31: newUser.url = evalURL(param.url);
32: newUser.registered = new Date();
33: newUser.blocked = 0;
34: // grant trust and sysadmin-rights if there's no sysadmin 'til now
35: if (root.manage.sysadmins.size() == 0)
36: newUser.sysadmin = newUser.trusted = 1;
37: else
38: newUser.sysadmin = newUser.trusted = 0;
39: if (path.Site) {
40: var welcomeWhere = path.Site.title;
41: // if user registered within a public site, we subscribe
42: // user to this site
43: if (path.Site.online)
44: this.add(new Membership(newUser));
45: } else
46: var welcomeWhere = root.getTitle();
47: return new Message("welcome", [welcomeWhere, newUser.name], newUser);
48: }
|