aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-12-15 22:00:20 -0500
committerCash Costello <cash.costello@gmail.com>2011-12-15 22:00:20 -0500
commitbc56428d493d99576ff274611df3b029e7e47e0a (patch)
tree7867e8cdc71cc8b0f70dbbf254dff7d0dc06753c /actions
parent49bb5234e9dbef676476bab2936344d8345065c9 (diff)
downloadelgg-bc56428d493d99576ff274611df3b029e7e47e0a.tar.gz
elgg-bc56428d493d99576ff274611df3b029e7e47e0a.tar.bz2
added some registration code for first time users
Diffstat (limited to 'actions')
-rw-r--r--actions/openid_client/login.php20
-rw-r--r--actions/openid_client/register.php34
2 files changed, 54 insertions, 0 deletions
diff --git a/actions/openid_client/login.php b/actions/openid_client/login.php
new file mode 100644
index 000000000..5e7ad3ace
--- /dev/null
+++ b/actions/openid_client/login.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ *
+ */
+
+elgg_load_library('openid_consumer');
+
+$store = new Auth_OpenID_FileStore('/tmp');
+
+$consumer = new ElggOpenIDConsumer($store);
+$consumer->setProvider('google');
+$consumer->setReturnURL(elgg_get_site_url() . 'mod/openid_client/return.php');
+
+$html = $consumer->requestAuthentication();
+if ($html) {
+ echo $html;
+ exit;
+} else {
+ register_error('oops');
+}
diff --git a/actions/openid_client/register.php b/actions/openid_client/register.php
new file mode 100644
index 000000000..e847d2395
--- /dev/null
+++ b/actions/openid_client/register.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Register an OpenID user
+ */
+
+elgg_set_context('openid_client');
+
+$username = get_input('username');
+$name = get_input('name');
+$email = get_input('email');
+$openid_identifier = get_input('openid_identifier');
+
+$password = 'test';
+
+try {
+ $guid = register_user($username, $password, $name, $email, false);
+} catch (RegistrationException $e) {
+ register_error($e->getMessage());
+ forward(REFERER);
+}
+$user = get_entity($guid);
+
+$user->openid_identifier = $openid_identifier;
+elgg_set_user_validation_status($guid, true, 'openid');
+
+if (!elgg_trigger_plugin_hook('register', 'user', array('user' => $user), true)) {
+ $user->delete();
+ register_error(elgg_echo('registerbad'));
+ forward(REFERER);
+}
+
+login($user);
+system_message($message);
+forward();