-
I don't know when this started happening but one of my customers told me he couldn't log in last week. If you click the person icon on the top-right and try to log in, it will just spin forever. This can be demonstrated at my staging site: https://6b5.042.myftpupload.com/ Note:
Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 7 replies
-
Hello, tested your site and log in works as expected. Your user may have a very slow connection. However, if you do not want to use the new AJAX login, simple disable it with a filter https://bootscore.me/documentation/woocommerce/#disable-ajax-login Solved? |
Beta Was this translation helpful? Give feedback.
-
@crftwrk, the autoupdater had already updated to 6.2 by the time you worked on it. I will leave it alone so it stays on 6.2. I have a feeling that this has something to do with the REST API and not bootscore at all. Does the ajax end up calling a REST route? I made a test for the shortcode [woocommerce_my_account] and it logs in as expected. https://6b5.042.myftpupload.com/test-page/ but I think that does a post back and doesn't use ajax. The reason why I suspect the REST is the problem is because sometimes I notice a strange message in the console about the user not logged in when it actually is. It doesn't seem to affect the site, however. This is the offending route: |
Beta Was this translation helpful? Give feedback.
-
Hello @cahoskins , As for your question. We are just using a custom ajax call. Thats it actually. |
Beta Was this translation helpful? Give feedback.
-
it seems that godaddy does not like the way we try to determin the ip adress to prohibit spamming the endpoint. If you replace the function bootscore_get_user_ip() with the following code you should be fine for now. Works now on staging. Will be implemented in bootscore soon i think ;) function bootscore_get_user_ip() {
global $user_ip;
if (!is_null($user_ip)) { // We've already discovered the browser's IP address.
return $user_ip;
}
if ( !empty($_SERVER['HTTP_CLIENT_IP']) ) {
$user_ip = filter_var($_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP);
} elseif ( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
$user_ip = filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP);
} else {
$user_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
}
// If no IP was found -> Check for X-Forwarded-For (godaddy)
if (empty($user_ip) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$forwarded_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach ($forwarded_ips as $ip) {
$ip = trim($ip);
if (filter_var($ip, FILTER_VALIDATE_IP)) {
$user_ip = $ip;
// The first found should be the correct one
break;
}
}
}
return $user_ip;
} |
Beta Was this translation helpful? Give feedback.
-
Am I able to override this in my child theme by putting it in: /bootscore-child/woocommerce/inc/wc-ajax-login.php ? |
Beta Was this translation helpful? Give feedback.
-
@cahoskins Thanks for asking for the logic, that pointed out a mistake i made when rewriting my debugging code for your site. I just added the section // If no IP was found -> Check for X-Forwarded-For (godaddy)
if (empty($user_ip) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$forwarded_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach ($forwarded_ips as $ip) {
$ip = trim($ip);
if (filter_var($ip, FILTER_VALIDATE_IP)) {
$user_ip = $ip;
// The first found should be the correct one
break;
}
}
} And actually it should take the first IP present in the list, not the last one. Overwriting of inc files is not "that" easy as for standard template files. You would have to unregister the original version of the file and then register your file in the child theme. |
Beta Was this translation helpful? Give feedback.
-
RE: unregister original version and then register my file in the child theme: I'm using an example from @crftwrk that did the unregister thing for the swiper init js (see below). Can you do the same thing with php files? I'm assuming I would need a path other than "get_stylesheet_directory_uri()" .
|
Beta Was this translation helpful? Give feedback.
-
Solved by #1051 @Axos11 Thank you 🙏 |
Beta Was this translation helpful? Give feedback.
-
Thank you both. And @Axos11, do you ever sleep? |
Beta Was this translation helpful? Give feedback.
@cahoskins
i did something similar with the ajax-cart before the changes were implemented into bootscore. basically you have to remove the action in bootscore/woocommerce/wc-functions.php and then hook your own function instead of it. That issue should be addressed with the next update anyways as my PR was already confirmed
Just look out. you have to use a remove_action in that case and look out that your removal hook runs after the registration but before the executio…