]>
Commit | Line | Data |
---|---|---|
f14f0b7b CP |
1 | import md5, os |
2 | from rc4 import RC4 | |
3 | ||
4 | def generate_url(config, obj): | |
5 | s = os.urandom(4) | |
6 | r = RC4(md5.md5("%s %s" % (s, config["urlkey"])).hexdigest()) | |
7 | a = r.crypt(obj["user.password"]) | |
8 | b = md5.md5(md5.md5("%s %s %s %s" % (config["urlsecret"], obj["user.username"], a, s)).hexdigest()).hexdigest() | |
9 | obj["url"] = "%s?m=%s&h=%s&u=%s&r=%s" % (config["url"], a.encode("hex"), b, obj["user.username"].encode("hex"), s.encode("hex")) | |
10 | ||
11 | MAILTEMPLATES = { | |
12 | "mutators": { | |
13 | 1: generate_url, | |
14 | }, | |
15 | ||
16 | "languages": { | |
17 | "en": { | |
18 | 1: { | |
19 | "subject": "New account registration", | |
20 | "body": """ | |
21 | Thank you for registering. | |
22 | ||
23 | Username: %(user.username)s | |
24 | Please visit %(url)s to get your password. | |
25 | """, | |
26 | }, | |
27 | 2: { "subject": "Password request", "body": "Your password: %(user.password)s", }, | |
28 | 3: { "subject": "New password", "body": "Your new password: %(user.password)s", }, | |
29 | 5: { "subject": "Email change", "body": "Your old email address: %(prevemail)s", }, | |
30 | }, | |
31 | }, | |
32 | } |