Post by 0xymoron » Thu Jul 25, 2024 1:24 pm

Hello once again! I'm hoping you guys can help me fix yet another mistake I've made on my shop, this time I was making some changes to fix my og:image not showing my product images correctly, I followed this guide here: https://dartharth.top/articles/short-ti ... opencart-3
I've got the og:image data working correctly now, however today I was trying to setup my mail server and noticed that I cannot create an account, instead I'm told that I need to accept the privacy policy and that all of my entries are incorrect. I can't find any errors that are being thrown that would lead to this, I'm sure one of you will know something that I don't though. Same as last time I'll gladly reward anyone who is able to help me solve this problem.
EDIT: it looks like I was doing something similar the last time I broke my shop, however this time I didn't insert my own messy code into my index.php

My store link is: https://oxytuned.com/shop
Image

Newbie

Posts

Joined
Thu Apr 27, 2023 1:26 am

Post by grgr » Thu Jul 25, 2024 2:32 pm

From this end it looks ok to me.
So have a look at ../catalog/controller/account/register.php
Disable any events and/or extensions that have anything to do with account/login/register
Have you got vQmod running, if so, check in there also.

-
Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by 0xymoron » Thu Jul 25, 2024 2:44 pm

grgr wrote:
Thu Jul 25, 2024 2:32 pm
From this end it looks ok to me.
So have a look at ../catalog/controller/account/register.php
Disable any events and/or extensions that have anything to do with account/login/register
Have you got vQmod running, if so, check in there also.
Thank you for the response!
I haven't modified register.php and I do not have vQmod installed.
I do know the website was working correctly prior to my changes involving the og:image data as I had an account created and order placed the night before.
I also enabled SEO urls, could that have something to do with it?
I've also tried on different browsers and devices with the same issue, can't create an account, login, or recover password, etc.

Here's my register.php just in case

Code: Select all

<?php
namespace Opencart\Catalog\Controller\Account;
class Register extends \Opencart\System\Engine\Controller {
	public function index(): void {
		if ($this->customer->isLogged()) {
			$this->response->redirect($this->url->link('account/account', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']));
		}

		$this->load->language('account/register');

		$this->document->setTitle($this->language->get('heading_title'));

		$data['breadcrumbs'] = [];

		$data['breadcrumbs'][] = [
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
		];

		$data['breadcrumbs'][] = [
			'text' => $this->language->get('text_account'),
			'href' => $this->url->link('account/account', 'language=' . $this->config->get('config_language'))
		];

		$data['breadcrumbs'][] = [
			'text' => $this->language->get('text_register'),
			'href' => $this->url->link('account/register', 'language=' . $this->config->get('config_language'))
		];

		$data['text_account_already'] = sprintf($this->language->get('text_account_already'), $this->url->link('account/login', 'language=' . $this->config->get('config_language')));

		$data['error_upload_size'] = sprintf($this->language->get('error_upload_size'), $this->config->get('config_file_max_size'));

		$data['config_file_max_size'] = ((int)$this->config->get('config_file_max_size') * 1024 * 1024);
		$data['config_telephone_display'] = $this->config->get('config_telephone_display');
		$data['config_telephone_required'] = $this->config->get('config_telephone_required');

		$this->session->data['register_token'] = substr(bin2hex(openssl_random_pseudo_bytes(26)), 0, 26);

		$data['register'] = $this->url->link('account/register.register', 'language=' . $this->config->get('config_language') . '&register_token=' . $this->session->data['register_token']);
		$data['upload'] = $this->url->link('tool/upload', 'language=' . $this->config->get('config_language'));

		$data['customer_groups'] = [];

		if (is_array($this->config->get('config_customer_group_display'))) {
			$this->load->model('account/customer_group');

			$customer_groups = $this->model_account_customer_group->getCustomerGroups();

			foreach ($customer_groups as $customer_group) {
				if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) {
					$data['customer_groups'][] = $customer_group;
				}
			}
		}

		$data['customer_group_id'] = $this->config->get('config_customer_group_id');

		// Custom Fields
		$data['custom_fields'] = [];

		$this->load->model('account/custom_field');

		$custom_fields = $this->model_account_custom_field->getCustomFields();

		foreach ($custom_fields as $custom_field) {
			if ($custom_field['location'] == 'account') {
				$data['custom_fields'][] = $custom_field;
			}
		}

		// Captcha
		$this->load->model('setting/extension');

		$extension_info = $this->model_setting_extension->getExtensionByCode('captcha', $this->config->get('config_captcha'));

		if ($extension_info && $this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('register', (array)$this->config->get('config_captcha_page'))) {
			$data['captcha'] = $this->load->controller('extension/'  . $extension_info['extension'] . '/captcha/' . $extension_info['code']);
		} else {
			$data['captcha'] = '';
		}

		$this->load->model('catalog/information');

		$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));

		if ($information_info) {
			$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information.info', 'language=' . $this->config->get('config_language') . '&information_id=' . $this->config->get('config_account_id')), $information_info['title']);
		} else {
			$data['text_agree'] = '';
		}

		$data['language'] = $this->config->get('config_language');

		$data['column_left'] = $this->load->controller('common/column_left');
		$data['column_right'] = $this->load->controller('common/column_right');
		$data['content_top'] = $this->load->controller('common/content_top');
		$data['content_bottom'] = $this->load->controller('common/content_bottom');
		$data['footer'] = $this->load->controller('common/footer');
		$data['header'] = $this->load->controller('common/header');

		$this->response->setOutput($this->load->view('account/register', $data));
	}

	public function register(): void {
		$this->load->language('account/register');

		$json = [];

		$keys = [
			'customer_group_id',
			'firstname',
			'lastname',
			'email',
			'telephone',
			'custom_field',
			'password',
			'confirm',
			'agree'
		];

		foreach ($keys as $key) {
			if (!isset($this->request->post[$key])) {
				$this->request->post[$key] = '';
			}
		}

		if (!isset($this->request->get['register_token']) || !isset($this->session->data['register_token']) || ($this->session->data['register_token'] != $this->request->get['register_token'])) {
			$json['redirect'] = $this->url->link('account/register', 'language=' . $this->config->get('config_language'), true);
		}

		if (!$json) {
			// Customer Group
			if ($this->request->post['customer_group_id']) {
				$customer_group_id = (int)$this->request->post['customer_group_id'];
			} else {
				$customer_group_id = (int)$this->config->get('config_customer_group_id');
			}

			$this->load->model('account/customer_group');

			$customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);

			if (!$customer_group_info || !in_array($customer_group_id, (array)$this->config->get('config_customer_group_display'))) {
				$json['error']['warning'] = $this->language->get('error_customer_group');
			}

			if ((oc_strlen($this->request->post['firstname']) < 1) || (oc_strlen($this->request->post['firstname']) > 32)) {
				$json['error']['firstname'] = $this->language->get('error_firstname');
			}

			if ((oc_strlen($this->request->post['lastname']) < 1) || (oc_strlen($this->request->post['lastname']) > 32)) {
				$json['error']['lastname'] = $this->language->get('error_lastname');
			}

			if ((oc_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
				$json['error']['email'] = $this->language->get('error_email');
			}

			$this->load->model('account/customer');

			if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
				$json['error']['warning'] = $this->language->get('error_exists');
			}

			if ($this->config->get('config_telephone_required') && (oc_strlen($this->request->post['telephone']) < 3) || (oc_strlen($this->request->post['telephone']) > 32)) {
				$json['error']['telephone'] = $this->language->get('error_telephone');
			}

			// Custom field validation
			$this->load->model('account/custom_field');

			$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);

			foreach ($custom_fields as $custom_field) {
				if ($custom_field['location'] == 'account') {
					if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['custom_field_id']])) {
						$json['error']['custom_field_' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
					} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !preg_match(html_entity_decode($custom_field['validation'], ENT_QUOTES, 'UTF-8'), $this->request->post['custom_field'][$custom_field['custom_field_id']])) {
						$json['error']['custom_field_' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_regex'), $custom_field['name']);
					}
				}
			}

			if ((oc_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) < 4) || (oc_strlen(html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8')) > 40)) {
				$json['error']['password'] = $this->language->get('error_password');
			}

			// Captcha
			$this->load->model('setting/extension');

			$extension_info = $this->model_setting_extension->getExtensionByCode('captcha', $this->config->get('config_captcha'));

			if ($extension_info && $this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('register', (array)$this->config->get('config_captcha_page'))) {
				$captcha = $this->load->controller('extension/' . $extension_info['extension'] . '/captcha/' . $extension_info['code'] . '.validate');

				if ($captcha) {
					$json['error']['captcha'] = $captcha;
				}
			}

			// Agree to terms
			$this->load->model('catalog/information');

			$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));

			if ($information_info && !$this->request->post['agree']) {
				$json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
			}
		}

		if (!$json) {
			$customer_id = $this->model_account_customer->addCustomer($this->request->post);

			// Login if requires approval
			if (!$customer_group_info['approval']) {
				$this->customer->login($this->request->post['email'], html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8'));

				// Add customer details into session
				$this->session->data['customer'] = [
					'customer_id'       => $customer_id,
					'customer_group_id' => $customer_group_id,
					'firstname'         => $this->request->post['firstname'],
					'lastname'          => $this->request->post['lastname'],
					'email'             => $this->request->post['email'],
					'telephone'         => $this->request->post['telephone'],
					'custom_field'      => $this->request->post['custom_field']
				];

				// Log the IP info
				$this->model_account_customer->addLogin($this->customer->getId(), $this->request->server['REMOTE_ADDR']);

				// Create customer token
				$this->session->data['customer_token'] = oc_token(26);
			}

			// Clear any previous login attempts for unregistered accounts.
			$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);

			unset($this->session->data['guest']);
			unset($this->session->data['register_token']);
			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);

			$json['redirect'] = $this->url->link('account/success', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''), true);
		}

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
}

Newbie

Posts

Joined
Thu Apr 27, 2023 1:26 am

Post by JNeuhoff » Thu Jul 25, 2024 5:16 pm

Your form fields are correctly send to the server via a POST request. However, the JSON response always is this:

Code: Select all

{"error":{"firstname":"First Name must be between 1 and 32 characters!","lastname":"Last Name must be between 1 and 32 characters!","email":"E-Mail Address does not appear to be valid!","password":"Password must be between 4 and 20 characters!","warning":"Warning: You must agree to the Privacy Policy!"}}
At this stage you may need a professional developer to look into it.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by 0xymoron » Thu Jul 25, 2024 5:53 pm

JNeuhoff wrote:
Thu Jul 25, 2024 5:16 pm
Your form fields are correctly send to the server via a POST request. However, the JSON response always is this:

Code: Select all

{"error":{"firstname":"First Name must be between 1 and 32 characters!","lastname":"Last Name must be between 1 and 32 characters!","email":"E-Mail Address does not appear to be valid!","password":"Password must be between 4 and 20 characters!","warning":"Warning: You must agree to the Privacy Policy!"}}
At this stage you may need a professional developer to look into it.
Are you able to look into it or can you recommend anyone who can?

Newbie

Posts

Joined
Thu Apr 27, 2023 1:26 am

Post by 0xymoron » Thu Jul 25, 2024 5:57 pm

UPDATE: I just disabled the only other thing I had been working on at the time which was SEO urls. Upon disabling that in the OpenCart settings I am immediately able to register a new account and login again. What gives?

Newbie

Posts

Joined
Thu Apr 27, 2023 1:26 am

Post by paulfeakins » Thu Jul 25, 2024 6:51 pm

0xymoron wrote:
Thu Jul 25, 2024 5:53 pm
Are you able to look into it or can you recommend anyone who can?
You could pay a developer such as ourselves or post a job in the Commercial Support Forum.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by 0xymoron » Fri Jul 26, 2024 7:48 am

I've got another update for anyone interested:
What caused the issue was enabling SEO-URLs then deleting the en-gb language entry from the "SEO URL" settings. I was advised to do this by another post I found here: viewtopic.php?t=230759#:~:text=Go%20to% ... lete%20it.
Upon re-enabling SEO URLs and re-adding the "en-gb language" entry to my SEO URLs everything appears to be working as intended again, I suppose I'll just need to deal with /en-gb/ being a part of my product URLs.
I'm not calling this issue solved however I've found a sort of workaround for my problem.

paulfeakins wrote:
Thu Jul 25, 2024 6:51 pm
0xymoron wrote:
Thu Jul 25, 2024 5:53 pm
Are you able to look into it or can you recommend anyone who can?
You could pay a developer such as ourselves or post a job in the Commercial Support Forum.
I'll be saving your website for anything I'll need in the future! I've got a lot of things I'll need done to this website that I'm definitely not capable of doing myself.

Newbie

Posts

Joined
Thu Apr 27, 2023 1:26 am

Post by webocreation.com » Fri Jul 26, 2024 10:28 am

It looks like your smtp is not sending email which could be one issues.
Upon checking the network request it is showing error like attached for me.

Image

Fixing the SMTP connection may fix that issue

Opencart 4 book for developers
Opencart 4 User Manual Book
Blog free tips and tricks
Free extensions
OpenCart Tutorials
OpenCart Tutorials Youtube Video for developers


User avatar
New member

Posts

Joined
Fri Feb 02, 2018 11:51 pm

Post by 0xymoron » Fri Jul 26, 2024 2:28 pm

webocreation.com wrote:
Fri Jul 26, 2024 10:28 am
It looks like your smtp is not sending email which could be one issues.
Upon checking the network request it is showing error like attached for me.

Image

Fixing the SMTP connection may fix that issue
The SMTP has been broken the entire time I've had the store online, I've only just recently started trying to get it to work. I've got email verification disabled so there's no *need* to have the email server working, it's just an inconvenience for customers at the moment.
I've got the website working right now, however if I try to remove the "en-gb" from the store's URL using the method I linked above the registration/login breaks.

Newbie

Posts

Joined
Thu Apr 27, 2023 1:26 am

Post by woa25 » Sun Jan 26, 2025 6:12 am

I had the same problem, so i disabled PHONE REQUIRED @ the Options page (ADMIN - SYSTEM - SETTINGS - 'Options' tab then account. I am now able to register new accounts.

Newbie

Posts

Joined
Sat Jan 25, 2025 10:01 pm
Who is online

Users browsing this forum: No registered users and 7 guests