diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-12-29 20:45:58 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-12-29 20:45:58 -0200 |
commit | 97e689213ff4e829f251af526ed4e796a3cc2b71 (patch) | |
tree | b04d03ec56305041216b72328fc9b5afde27bc76 /mod/openid_client/actions | |
parent | 0ab6351abb7a602d96c62b0ad35413c88113a6cf (diff) | |
parent | 69e2d8c5d8732042c9319aef1fdea45a82b63e42 (diff) | |
download | elgg-97e689213ff4e829f251af526ed4e796a3cc2b71.tar.gz elgg-97e689213ff4e829f251af526ed4e796a3cc2b71.tar.bz2 |
Merge branch 'master' into saravea
Conflicts:
.gitmodules
mod/admins
mod/assemblies
mod/audio_html5
mod/beechat
mod/crud
mod/elgg-activitystreams
mod/elggman
mod/elggpg
mod/favorites
mod/federated-objects
mod/friendly_time
mod/group_alias
mod/group_operators
mod/languages
mod/lightpics
mod/openid_client
mod/spotlight
mod/suicide
mod/tasks
mod/videolist
Diffstat (limited to 'mod/openid_client/actions')
-rw-r--r-- | mod/openid_client/actions/openid_client/login.php | 32 | ||||
-rw-r--r-- | mod/openid_client/actions/openid_client/register.php | 35 |
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(); |