changepassword.php 844 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Action to reset a password, send success email, and log the user in.
  4. *
  5. * @package Elgg
  6. * @subpackage Core
  7. */
  8. $password = get_input('password1');
  9. $password_repeat = get_input('password2');
  10. $user_guid = get_input('u');
  11. $code = get_input('c');
  12. try {
  13. validate_password($password);
  14. } catch(RegistrationException $e) {
  15. register_error($e->getMessage());
  16. forward(REFERER);
  17. }
  18. if ($password != $password_repeat) {
  19. register_error(elgg_echo('RegistrationException:PasswordMismatch'));
  20. forward(REFERER);
  21. }
  22. if (execute_new_password_request($user_guid, $code, $password)) {
  23. system_message(elgg_echo('user:password:success'));
  24. try {
  25. login(get_entity($user_guid));
  26. } catch (LoginException $e) {
  27. register_error($e->getMessage());
  28. forward(REFERER);
  29. }
  30. } else {
  31. register_error(elgg_echo('user:password:fail'));
  32. }
  33. forward();