setError(Text::get('invalidFormError')); } if ($newPassword1 !== $newPassword2) { return $Response->setError(Text::get('passwordRepeatError')); } if ($currentPassword === $newPassword1) { return $Response->setError(Text::get('passwordReuseError')); } $UserCollection = new UserCollection(); $User = $UserCollection->getUser(Session::getUsername()); $Messenger = new Messenger(); if (!$User) { return $Response->setError(Text::get('userNotFoundError')); } $User->changePassword($currentPassword, $newPassword1, $UserCollection, $Messenger); return $Response ->setError($Messenger->getError()) ->setSuccess($Messenger->getSuccess()); } /** * Edit user account info such as username and email. * * @return Response the response */ public static function edit(): Response { $Response = new Response(); $Messenger = new Messenger(); $UserCollection = new UserCollection(); $username = Request::post('username'); $email = Request::post('email'); if ($UserCollection->editCurrentUserInfo($username, $email, $Messenger)) { if ($UserCollection->save($Messenger)) { return $Response->setSuccess(Text::get('savedSuccess')); } } return $Response->setError($Messenger->getError()); } /** * Reset a user password by email. * * @return Response the Response object */ public static function resetPassword(): Response { $Response = new Response(); $UserCollection = new UserCollection(); $Messenger = new Messenger(); // Only one field will be defined, so they can just be concatenated here. $nameOrEmail = trim(Request::post('name-or-email') . Request::post('username')); $token = Request::post('token'); $newPassword1 = Request::post('password1'); $newPassword2 = Request::post('password2'); $User = $UserCollection->getUser($nameOrEmail); if ($nameOrEmail && !$User) { return $Response->setError(Text::get('userNotFoundError')); } if (!$User) { return $Response->setData(array('state' => 'requestToken')); } $responseData = array('username' => $User->name); if ($token && $newPassword1 && $newPassword2) { if ($User->verifyPasswordResetToken($token)) { if ($User->resetPassword($newPassword1, $newPassword2, $UserCollection, $Messenger)) { $responseData['state'] = 'success'; return $Response->setData($responseData); } $responseData['state'] = 'setPassword'; return $Response->setData($responseData)->setError($Messenger->getError()); } $responseData['state'] = 'setPassword'; return $Response->setData($responseData)->setError(Text::get('passwordResetVerificationError')); } if ($User->sendPasswordResetToken($Messenger)) { $responseData['state'] = 'setPassword'; return $Response->setData($responseData); } return $Response->setError($Messenger->getError()); } } __halt_compiler();----SIGNATURE:----F0HizaercOaEI1z/TG4BTDECtpFmBQ2h13VT3y6hV458cztt/IFlkAhk603/sm/wOaQNDT8aYaQoNDCqzbS5YZr2r7YJZtZ5ZEi1gTBMBfwy2hftBjIGw70aBdUFE/t7bUD8Pncy3VIZKmtOYB9PO423aRp37hxw0T+hmPDO0ITc2egqlB34l+Wllgs1k+cEbAYGczguQ3wovky2vxCWyjJEfn3Cck+QtxK/XvBfePuM5ja9QBQq6GREvzeOadHUZL5q//vvabAL5X+YEqBLr46SeDEGvTjESa3rNtWcwYwJOPH/CWZrfx+HIgteUhYA1+cYUx9DuUNMNLPS97BP0VwVgezWnJzNkzfREPZrcSCBR2DRphE3H8kZb5WoCYg2aKOBX1XLsmYbs/hgPRaT/vUqjOlPFBF1BZkDgiRPi6p9ujqb55ijm7/sDWpFsDAr1JUPqR0n2EdNzvI+C+24lvP07A7ez2HTq1RNlGDIINHP1ruPuDNWZG5igLRpPOu8sDn28fifGQM8g9NIZtwTXFYOIaTUhcnhxeBZ30ofd0uDA3nNIM/QRmPecZiIb48HXucImvSoCl00lJT2s8EgkBWY9Pmp4njjqR0ae+iBkBEHYTC9mATrniji1gfOJnZzz/GlW61j8IJY1rFrLN5nFzIHI2TwMZ3exMQzWa3Wj8E=----ATTACHMENT:----MjQ0MDk2ODIyNzU4NTg0IDEzMDQ4Mjk5ODMyNDQ4OTUgNTY5MzY2MTYyMDAyNzUyMw==