Elgg  Version 4.3
changepassword.php
Go to the documentation of this file.
1 <?php
8 
9 $password = get_input('password1', null, false);
10 $password_repeat = get_input('password2', null, false);
11 $user_guid = (int) get_input('u');
13 
14 try {
15  elgg()->accounts->assertValidPassword($password);
16 } catch (RegistrationException $e) {
17  return elgg_error_response($e->getMessage());
18 }
19 
20 if ($password !== $password_repeat) {
21  return elgg_error_response(elgg_echo('RegistrationException:PasswordMismatch'));
22 }
23 
25 if (!$user instanceof \ElggUser || !elgg_save_new_password($user, $code, $password)) {
26  return elgg_error_response(elgg_echo('user:password:fail'));
27 }
28 
29 try {
31 } catch (LoginException $e) {
32  return elgg_error_response($e->getMessage());
33 }
34 
35 return elgg_ok_response('', elgg_echo('user:password:success'), '');
$user_guid
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
Elgg registration action.
Generic parent class for login exceptions.
elgg_save_new_password(\ElggUser $user, string $conf_code, string $password=null)
Validate and change password for a user.
Definition: users.php:80
Could not register a new user for whatever reason.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
catch(RegistrationException $e) if($password!==$password_repeat) $user
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
$password
$password_repeat
elgg_login(\ElggUser $user, bool $persistent=false)
Log in a user.
Definition: sessions.php:81
elgg_error_response($message= '', $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
elgg_ok_response($content= '', $message= '', $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
Login as the specified user.
var elgg
Definition: elgglib.js:4