Author Topic: account activation link problem  (Read 113346 times)

bart198x

  • Beginner
  • *
  • Posts: 29
Re: account activation link problem
« Reply #30 on: December 02, 2012, 10:40:50 am »
for Lipes. That's why for registration I use joomla form with recaptcha. After proper registration the 'Registration' link changes to 'Your details' - directing not to registration but to edit_address_userfields.php where user can complete registration data :) little around but works. only one thing is annoyng me the TOS checkbox is not working correctly on edit_address_userfields.php (1. is not required actualy, 2. and does't display corectly it's value from data base - the state in DB is 1 but it's not checked in form for e.g.). If there is solution to TOS in edit_address_userfields.php please direct me on topic, after 2 days I still can't find it (I read a lot topics from forum with no solution, on cart I fixed TOS with one of them :) ).

Makis77

  • Beginner
  • *
  • Posts: 49
Re: account activation link problem
« Reply #31 on: December 08, 2012, 01:06:34 am »
I m having the same issues as well.

coruja

  • Beginner
  • *
  • Posts: 12
Re: account activation link problem
« Reply #32 on: December 12, 2012, 08:23:05 am »
I am new to VM 2 and I have been trying to solve this issue for week or so.

The behaviour seems very erratic, it was not working at all (just re-directing me to the home page)  but when I added a .htaccess redirect from non-www to www it worked once or twice.
I am not sure if that was because  I had cleared down the cache and/or not 'logged in' to VM at the time.

I have then tried using KC VM Registration Redirect plug-in from the JED which did not seem to help. I have since uninstalled it.
However, I am now getting another another error "Registration failed: Verification code not found"

I am ready to try Bedrock's workaround but I am not sure what the '../yourregistrationpage' URL, as mentioned below, should be. Could someone please point me in the right direction?

Not very elegantly, but I solved the problem.
First you have to put a script to the beginning of the "components/com_virtuemart/views/user/tmpl/edit_address_userfields.php" file.

Code: [Select]
<script language="javascript">
if ('<?php echo $_SERVER[HTTP_HOST]; ?>' == 'www.yourdomain.com')
{
location.href="http://yourdomain.com/yourregistrationpage" ;
}
</script>

This way it redirects the visitor if s/he arrived from a "www" domain to the registration page, so this way you cannot register from a "www" domain.

Then you have to modify the activation email's activation link that can be found in the "components/com_virtuemart/views/user/tmpl/mail_html_reguser.php"  file.

This has to be modified (53th row):
Code: [Select]
$activationLink = '<a class="default" href="' . JURI::root() . $this->activationLink . '">' . JText::_('COM_VIRTUEMART_LINK_ACTIVATE_ACCOUNT') . '</a>';

To this:
Code: [Select]
$modifiedlink = str_replace ("http://","http://www.",JURI::root());

$activationLink = '<a class="default" href="' . $modifiedlink . $this->activationLink . '">' . JText::_('COM_VIRTUEMART_LINK_ACTIVATE_ACCOUNT') . '</a>';

So the user will get a "www" activation link and with that the account can be activated.

best regards
bedrock
Joomla 2.5.8    VM 2.0.14   PHP 5.2.18

coruja

  • Beginner
  • *
  • Posts: 12
Re: account activation link problem
« Reply #33 on: December 19, 2012, 04:29:30 am »
Hello,

I would really appreciate some help with my post above ^.  A lot of the solutions posted on VM forums seem to be targeted at experienced PHP developers hence novices to VM and PHP would struggle to understand them.
Joomla 2.5.8    VM 2.0.14   PHP 5.2.18

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #34 on: December 20, 2012, 17:40:07 pm »
Good point bart198x, but we do that imho correct, controller user.php line 200
Code: [Select]
$usersConfig = JComponentHelper::getParams( 'com_users' );
$useractivation = $usersConfig->get( 'useractivation' );
if (is_array($ret) and $ret['success'] and !$useractivation) {
// Username and password must be passed in an array
$credentials = array('username' => $ret['user']->username,
  'password' => $ret['user']->password_clear
);
$return = $mainframe->login($credentials);
}

Maybe the $mainframe->login($credentials); is not working as expected. What we want to prevent is that user must login while the checkout.

I had the same activation link problem. It worked only when I manually added www to the activation link.
Finally did what Bedrock suggested. Not exactly nice, but efficient.

Thanks Bedrock!

@Milbo
"I think you make www as alias, that is wrong"
I don't get it. Can you please elaborate on this assumption?

This is a server configuration issue. If you start to mix your domains. Most people have only a www domain or a domain without www. In fact the www is just a subdomain. so a www.domain.com exists almost always also as "domain.com". You can configurate the behaviour different. Imho the best solution is to use only with www or without www.

So if you can browse your page with or without www, without being redirected you may get in trouble. Imho this is the real problem behind it.

This is the reason we neglect this problem the last 3 months, because it is often a misconfigured server. Additionally to that it is usually not good to force shoppers todo a double optin.

Even someone pointed out that all other components work well, is the question how many components allow login? So it is strange to see that some people can just solve it changing joomla,  http://forum.virtuemart.net/index.php?topic=103992.msg373624#msg373624 .

Other users noticed also that they have the issue on some servers and on others not. So it is not clearly a Virtuemart problem
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

tomh

  • Beginner
  • *
  • Posts: 1
Re: account activation link problem
« Reply #35 on: January 03, 2013, 17:12:50 pm »
What we found out today:

Virtuemart with the following settings enabled:
x Registration on checkout
x only registered users can checkout

Situation:
  • A GUEST wants to order something.
  • He puts some products into the cart.
  • At the end he clicks on Checkout.
  • Guest gets redirected to step 2 - billing address.
  • Guest enters his address and clicks on Next.
  • E-Mail with confirmation code is sent to his e-mail address.

Ok, let's stop here.

Until here, everything is fine, but afterwards it's getting complicated...

Situation 1:
  • Guest clicks on the activation link in his e-mail inbox.
  • Guest gets logged in and redirected to cart.
  • Everything works.


Situation 2:
  • Guest does not click on the activation link, instead he continues the ordering process.
  • Guest is no guest anymore, he is logged in with the username he created before. -> That's where the problem is. Because he got logged in, the field lastvisitDate in the database got changed from 0000-00-00 00:00:00 to the current date.
  • User completes the ordering process.
  • User clicks on the activation link in the e-mail.
  • Activation fails. User stays inactive and blocked.

Because of the change of the lastvisitDate, the joomla internal activation mechanisms don't work anymore. There's a check for a null-date in the SQL statement that gets executed when clicking the link. The activation code is stored in the user entry in the database.

So, joomla looks after the activation code together with a null-date and a user id. Activation code and user id do match, but the null-date does not.

Solutions:

  • Disable e-mail verification
  • Hack Joomla core and disable lastvisitDate verification
  • Hack Virtuemart core and insert a check if user is activated or not. Do not let the user continue until he activated his account

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #36 on: January 04, 2013, 16:20:02 pm »
Great written tomh,

But then this is a joomla problem from my point of view. Why they do this check?

and I just checked the code, we do
Code: [Select]
if($currentUser->guest==1){
$msg = (is_array($ret)) ? $ret['message'] : $ret;
$usersConfig = JComponentHelper::getParams( 'com_users' );
$useractivation = $usersConfig->get( 'useractivation' );
if (is_array($ret) and $ret['success'] and !$useractivation) {
// Username and password must be passed in an array
$credentials = array('username' => $ret['user']->username,
  'password' => $ret['user']->password_clear
);
$return = $mainframe->login($credentials);
}
}

So the user is only logged in if he is guest and if the useractivation is set to 0, none, nada, nix. GRmBL!
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

dnlvsci

  • Jr. Member
  • **
  • Posts: 50
Re: account activation link problem
« Reply #37 on: January 04, 2013, 22:08:08 pm »
you are wrong milbo. this isn't joomla problem because: If you register in the cart or the index.php?option=com_virtuemart&view=user&layout=edit or the index.php?option=com_virtuemart&view=user&layout=editadress link you logged in automaticall by th VM. If you see the joomla login module that show you aren't logged in but if you go to the VM profile page (index.php?option=com_virtuemart&amp;view=user&amp;layout=default) this show you are logged in..... If you try to login in the normal joomla login module or link you can't because you ar in the joomla. After I returned on my profile page, logged out, but I cant login because I can't activate my account.

As tomh said -> the joomla wrote the last visite date and kill the activate method. If I revrite my last visit to 0000-00-00 00:00:00 I can activate my account.

I think if VM can be force logout me after the order thank mail sent, and can be revrite the last visit date 0000-00-00 00:00:00 (if block = 1 in the jos_users) the problem will be solve. This solve if you register in the cart, but not solve if you register in index.php?option=com_virtuemart&view=user&layout=edit/editadress page. The best solution if the Vm check user blocked and activation status and revrite the last login date if necessary

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #38 on: January 07, 2013, 01:31:39 am »
I wonder if you can read php. What I just said before is that we do this check. People should not be logged in IF there is a useractivation set. So the question is what is wrong in our code, which I posted above.
Code: [Select]
if (is_array($ret) and $ret['success'] and !$useractivation) {

I think atm the problem is maybe that we store the stuff and this is maybe writing another date in it. But still i do not really understand why joomla is performing this check, why is it necessary? There is any sense behind it?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #39 on: January 07, 2013, 01:42:52 am »
I do not understand why it is logging in, there is only one place in the code and it was not called. However I set now in the usermodel line 625
Code: [Select]
$user->set('lastvisitDate', '0000-00-00 00:00:00');

Maybe it works, would be nice. At least this value is in the db, after I did the registration. Also funny that I see the correct messages from joomla, that I should check my email.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

dnlvsci

  • Jr. Member
  • **
  • Posts: 50
Re: account activation link problem
« Reply #40 on: January 07, 2013, 14:39:20 pm »
Not working. You send the 0000-00-00 00:00:00 date when you register, but joomla rewrite the date when you logged out from virtuemart profile page. If you don't logout, and you click the activation link you get a blank white page, if you logged out, and click the activation link you get error. I attached a picture to show you what happen. I bought something, registered in the cart, and after the order I go to my profile page....

[attachment cleanup by admin]

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #41 on: January 07, 2013, 20:32:49 pm »
I know what you mean, but still we dont understand how it does the login.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #42 on: January 07, 2013, 23:24:45 pm »
Digged deeper into the problem

disable in /libraries/joomla/user.php the lines
Code: [Select]
if (empty($this->id))
{
$this->id = $table->get('id');
}

around line 814

The solution seems to use NOT the joomla method to store users which should activated.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

dnlvsci

  • Jr. Member
  • **
  • Posts: 50
Re: account activation link problem
« Reply #43 on: January 08, 2013, 17:35:26 pm »
Not a good solution. If I register, now I not logged in, but the activation link doesn't sent. If I try to register in cart, tha page say "Please register to checkout" or "User name in use" :(

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: account activation link problem
« Reply #44 on: January 08, 2013, 17:48:00 pm »
It is not a solution, it should just show that as long we use joomla native save method, it is doing the error.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/