Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

actions/user/changepassword.php (1 issue)

1
<?php
2
/**
3
 * Action to reset a password, send success email, and log the user in.
4
 */
5
6
$password = get_input('password1');
7
$password_repeat = get_input('password2');
8
$user_guid = (int) get_input('u');
9
$code = get_input('c');
10
11
try {
12
	validate_password($password);
13
} catch (RegistrationException $e) {
14
	return elgg_error_response($e->getMessage());
15
}
16
17
if ($password != $password_repeat) {
18
	return elgg_error_response(elgg_echo('RegistrationException:PasswordMismatch'));
19
}
20
21
if (!execute_new_password_request($user_guid, $code, $password)) {
22
	return elgg_error_response(elgg_echo('user:password:fail'));
23
}
24
25
try {
26
	login(get_user($user_guid));
0 ignored issues
show
get_user($user_guid) of type false is incompatible with the type ElggUser expected by parameter $user of login(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
	login(/** @scrutinizer ignore-type */ get_user($user_guid));
Loading history...
27
} catch (LoginException $e) {
28
	return elgg_error_response($e->getMessage());
29
}
30
31
return elgg_ok_response('', elgg_echo('user:password:success'));
32