summaryrefslogtreecommitdiff
path: root/actions/finishopenidlogin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-04-17 12:52:26 -0700
committerEvan Prodromou <evan@controlyourself.ca>2009-04-17 12:52:26 -0700
commit231c61a7eb3bb79faed696945ccd6d831c80f0f2 (patch)
tree1cbc15c9a8b3628b824d067679780bcb17c77f15 /actions/finishopenidlogin.php
parent34d904b180e5caa17eb945292a8a64656424d5d0 (diff)
store invite code in session so openidfinish can find it
Diffstat (limited to 'actions/finishopenidlogin.php')
-rw-r--r--actions/finishopenidlogin.php33
1 files changed, 28 insertions, 5 deletions
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index 952185742..b08b96df6 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -191,11 +191,28 @@ class FinishopenidloginAction extends Action
{
# FIXME: save invite code before redirect, and check here
- if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
+ if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
return;
}
+ $invite = null;
+
+ if (common_config('site', 'inviteonly')) {
+ $code = $_SESSION['invitecode'];
+ if (empty($code)) {
+ $this->clientError(_('Registration not allowed.'));
+ return;
+ }
+
+ $invite = Invitation::staticGet($code);
+
+ if (empty($invite)) {
+ $this->clientError(_('Not a valid invitation code.'));
+ return;
+ }
+ }
+
$nickname = $this->trimmed('newname');
if (!Validate::string($nickname, array('min_length' => 1,
@@ -257,10 +274,16 @@ class FinishopenidloginAction extends Action
# XXX: add language
# XXX: add timezone
- $user = User::register(array('nickname' => $nickname,
- 'email' => $email,
- 'fullname' => $fullname,
- 'location' => $location));
+ $args = array('nickname' => $nickname,
+ 'email' => $email,
+ 'fullname' => $fullname,
+ 'location' => $location);
+
+ if (!empty($invite)) {
+ $args['code'] = $invite->code;
+ }
+
+ $user = User::register($args);
$result = oid_link_user($user->id, $canonical, $display);