Elgg  Version 6.0
changepassword.php
Go to the documentation of this file.
1 <?php
8 
9 $password = (string) get_input('password1', '', false);
10 $password_repeat = (string) get_input('password2', '', false);
11 $user_guid = (int) get_input('u');
12 $code = (string) get_input('c');
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:changepassword:unknown_user'));
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'), '');
elgg
Definition: install.js:27
$user_guid
Elgg registration action.
Generic parent class for login exceptions.
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_save_new_password(\ElggUser $user, string $conf_code, string $password=null)
Validate and change password for a user.
Definition: users.php:131
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
Could not register a new user for whatever reason.
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
catch(RegistrationException $e) if($password!==$password_repeat) $user
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
$password
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
$password_repeat
elgg_login(\ElggUser $user, bool $persistent=false)
Log in a user.
Definition: sessions.php:81
Login as the specified user.