I just installed this, fresh out of the box the email that gets sent to the user has "[user:one-time-login-url]" where the actual token replacement should be. The "user account created by administrator" email that used to get sent before this module took over store emails did actually have the proper token replacement.

What do I need to do to get the out of the box module to work properly?

I'll post back here what I can find but I assume I'm not the only one to encounter this. Any guidance would be greatly appreciated.

thanks

CommentFileSizeAuthor
#12 1864350.patch524 bytesrsamsen

Comments

tmsimont’s picture

Category: support » bug
Priority: Normal » Major

This is actually a pretty big deal -- it makes it impossible for new users to actually log into the website.

tmsimont’s picture

I've been testing a bit and confirm that none of the following tokens are converted to real values in this email:

  • [user:one-time-login-url]
  • [account-fetched:one-time-login-url]
  • [account-created:one-time-login-url]
  • [account_fetched:one-time-login-url]
  • [account_created:one-time-login-url]
ransomweaver’s picture

I had previously worked around this by using php in the email at admin/commerce/config/email like so:

<?php
$resetUrl =  user_pass_reset_url($account); 
?>
<p><a href="<?php print $resetUrl;?>"><?php print $resetUrl;?></a></p>

However this stopped working for some reason so my new workaround is this:

Edit the rule supplied by commerce_email here: /admin/config/workflow/rules/reaction/manage/commerce_email_new_account
In the loop at the end, add a new action (system:send email)
for To: use [user:mail]
for message just copy what is in admin/commerce/config/email for the account email.
delete the "send variable email" from the loop.
edit the account email in admin/commerce/config/email to say something like DUE TO A BUG THIS EMAIL IS NOT USED. and say how to find the rule that needs editing.

NOTE: you need to check that rules can resolve the one-time-login token. check in the tokens list in the email action to see that its there. If its not, you probably have to put this patch into rules:
http://drupal.org/files/1289898-rules-restricted-user-tokens.patch
which is super easy to do by hand.

I'm not sure if that's necessary. I just haven't tested without it.

michiellucas’s picture

Priority: Major » Critical

Same problem, nobody working on this issue?

Pretty big issue because it is destroying the anonymous users

tmsimont’s picture

#3 works for me, but it would be nice to see this fixed for this module so those steps aren't necessary

zengenuity’s picture

Just want to confirm that the steps in #3 worked for me, too.

daniel wentsch’s picture

Seems to be an issue with Variable Email: #1430694: [user:one-time-login-url] is not available on config page, so new user cannot log in

Edit: now with correct issue link

xurizaemon’s picture

Status: Active » Closed (duplicate)

See #1430694: [user:one-time-login-url] is not available on config page, so new user cannot log in. Note that the fix in that issue requires uncommenting a couple of lines.

joey-santiago’s picture

My workaround has been:

/**
 * Implements hook_mail_alter()
 * 
 * Altering the email created by commerce_email_account in order to fix
 * http://drupal.org/node/1289898 
 * https://www.drupal.org/node/1864350
 * the one time login token is not rendered.
 */
function mymodule_commerce_mail_alter(&$message){
  if(isset($message['key'])){
    if($message['key'] == "commerce_email_account"){
      if(isset($message['body'][0]) && isset($message['to'])){
        //the account has been created through a rule.
        $account = user_load_by_mail($message['to']);
        if(!is_object($account)){
          return;
        }
        $login_link = user_pass_reset_url($account);
        $message['body'][0] = str_replace("[user:one-time-login-url]", $login_link, $message['body'][0]);
      }
    }
  }
}
dtamajon’s picture

I think solution should be on Token module, where the token is declared:

diff --git a/sites/all/modules/token/token.tokens.inc b/sites/all/modules/token/token.tokens.inc
index e0c0b5e..979dfbc 100644
--- a/sites/all/modules/token/token.tokens.inc
+++ b/sites/all/modules/token/token.tokens.inc
@@ -571,6 +571,9 @@
           $roles = array_intersect_key(user_roles(), $account->roles);
           $replacements[$original] = token_render_array($roles, $options);
           break;
+        case 'one-time-login-url':
+          $replacements[$original] = user_pass_reset_url($account);
+          break;
       }
     }

This is not the only token not replaced, so Tokens module should be reviewed to add those replacements.

Damn-Deal-Done’s picture

Issue summary: View changes

#10 solved this problem for me.

rsamsen’s picture

StatusFileSize
new524 bytes

I've created a patch based on #10, as this also solves my problem.
Bear with me, my first patch in the community. So I'm not sure what to do next ;)