summaryrefslogtreecommitdiff
path: root/actions/register.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2008-06-20 01:15:36 -0400
committerEvan Prodromou <evan@controlyourself.ca>2008-06-20 01:15:36 -0400
commitbf0be3ddb7226f428a3cc00a87c5a64f2113c00b (patch)
treef39f275c5ada6dc79d835eb78101596fd003f368 /actions/register.php
parent8ecd2a6b1dcfb21fae9a70bba65dfff3bb7503f1 (diff)
confirm email addresses
darcs-hash:20080620051536-5ed1f-231e427832dd20c861eb7a6dc1171315e90f455b.gz
Diffstat (limited to 'actions/register.php')
-rw-r--r--actions/register.php30
1 files changed, 26 insertions, 4 deletions
diff --git a/actions/register.php b/actions/register.php
index cad5c2ed7..d9315b424 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -89,8 +89,11 @@ class RegisterAction extends Action {
}
function register_user($nickname, $password, $email) {
- # TODO: wrap this in a transaction!
+
$profile = new Profile();
+
+ $profile->query('BEGIN');
+
$profile->nickname = $nickname;
$profile->profileurl = common_profile_url($nickname);
$profile->created = DB_DataObject_Cast::dateTime(); # current time
@@ -103,15 +106,34 @@ class RegisterAction extends Action {
$user->id = $id;
$user->nickname = $nickname;
$user->password = common_munge_password($password, $id);
- $user->email = $email;
$user->created = DB_DataObject_Cast::dateTime(); # current time
$user->uri = common_mint_tag('user:'.$id);
$result = $user->insert();
if (!$result) {
- # Try to clean up...
- $profile->delete();
+ return FALSE;
}
+
+ if ($email) {
+ $confirm = new Confirm_email();
+ $confirm->code = common_good_random(16);
+ $confirm->user_id = $user->id;
+ $confirm->email = $email;
+
+ $result = $confirm->insert();
+ if (!$result) {
+ return FALSE;
+ }
+ }
+
+ $profile->query('COMMIT');
+
+ if ($email) {
+ mail_confirm_address($code,
+ $profile->nickname,
+ $email);
+ }
+
return $result;
}