aboutsummaryrefslogtreecommitdiff
path: root/actions/openid_client/register.php
blob: c4d3501ed189176df079e424626682420dea9e67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?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);

$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(elgg_echo('openid_client:success:register'));
forward();