aboutsummaryrefslogtreecommitdiff
path: root/mod/openid_client/actions
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:25:34 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:25:34 +0100
commit2161e2335c9c650b8e44a56f6c9b0bd37546ae1f (patch)
tree91bef55b773a7a80b5f6a065411574bdbe9fe522 /mod/openid_client/actions
parenta9ac4c861335e60373c1e99b61372e6e0d6ac9f4 (diff)
parent11ea6ae4734a0e722c6ecaaee90e9ab772e8d2cc (diff)
downloadelgg-2161e2335c9c650b8e44a56f6c9b0bd37546ae1f.tar.gz
elgg-2161e2335c9c650b8e44a56f6c9b0bd37546ae1f.tar.bz2
Add 'mod/openid_client/' from commit '11ea6ae4734a0e722c6ecaaee90e9ab772e8d2cc'
git-subtree-dir: mod/openid_client git-subtree-mainline: a9ac4c861335e60373c1e99b61372e6e0d6ac9f4 git-subtree-split: 11ea6ae4734a0e722c6ecaaee90e9ab772e8d2cc
Diffstat (limited to 'mod/openid_client/actions')
-rw-r--r--mod/openid_client/actions/openid_client/login.php32
-rw-r--r--mod/openid_client/actions/openid_client/register.php35
2 files changed, 67 insertions, 0 deletions
diff --git a/mod/openid_client/actions/openid_client/login.php b/mod/openid_client/actions/openid_client/login.php
new file mode 100644
index 000000000..2a6896a61
--- /dev/null
+++ b/mod/openid_client/actions/openid_client/login.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * OpenID client login action
+ */
+
+elgg_load_library('openid_consumer');
+
+$provider = get_input('openid_provider');
+$persistent = get_input('persistent', false);
+
+if ($provider == 'others') {
+ $provider = get_input('openid_url');
+}
+
+$consumer = new ElggOpenIDConsumer($store);
+$consumer->setURL($provider);
+$consumer->setReturnURL(elgg_get_site_url() . "mod/openid_client/return.php?persistent=$persistent");
+
+$html = $consumer->requestAuthentication();
+if ($html) {
+ echo $html;
+ exit;
+} else {
+ $flipped_providers = array_flip(elgg_get_config('openid_providers'));
+ if (isset($flipped_providers[$provider])) {
+ $provider_name = $flipped_providers[$provider];
+ } else {
+ $provider_name = $provider;
+ }
+ register_error(elgg_echo('openid_client:error:no_html', array($provider_name)));
+ forward();
+}
diff --git a/mod/openid_client/actions/openid_client/register.php b/mod/openid_client/actions/openid_client/register.php
new file mode 100644
index 000000000..f0ad2a5fd
--- /dev/null
+++ b/mod/openid_client/actions/openid_client/register.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Register OpenID user action
+ */
+
+elgg_set_context('openid_client');
+
+$username = get_input('username');
+$name = get_input('name');
+$email = get_input('email');
+$openid_identifier = get_input('openid_identifier');
+
+$password = generate_random_cleartext_password();
+
+try {
+ $guid = register_user($username, $password, $name, $email, false);
+} catch (RegistrationException $e) {
+ register_error($e->getMessage());
+ forward(REFERER);
+}
+$user = get_entity($guid);
+openid_client_set_subtype($user);
+
+$user->annotate('openid_identifier', $openid_identifier, ACCESS_PUBLIC);
+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(elgg_echo('openid_client:success:register'));
+forward();