_route = 'users/{user}/verify'; $this->_module = 'Core'; $this->_description = 'Validate/Activate a NamelessMC account by confirming their reset code'; $this->_method = 'POST'; } public function execute(Nameless2API $api, User $user): void { $api->validateParams($_POST, ['code']); if ($user->data()->active || $user->data()->reset_code == '') { $api->throwError(CoreApiErrors::ERROR_USER_ALREADY_ACTIVE); } if ($user->data()->reset_code != $_POST['code']) { $api->throwError(CoreApiErrors::ERROR_INVALID_CODE); } $user->update([ 'active' => true, 'reset_code' => null, ]); EventHandler::executeEvent(new UserValidatedEvent( $user, )); $api->returnArray(['message' => $api->getLanguage()->get('api', 'account_validated')]); } }