Download & Extend

expose a token for login url for use elsewhere

Project:Easy Login
Version:6.x-1.0
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

I'm using simplenews to email my users and I would like to find a way to embed a url to a specific node that automatically logs them in.

(I'm new to this so bear with me..:)

The logic would go something like:
- create newsletter
- embed link {autologin}url
- hit send - the {autologin} is replaced with user/subscriber specific info [username/pass]
- user finds himself logged in and looking at the node/page I wanted.

I am hoping your Easylogin module can help but do you have any ideas how i could tweak it to help me achieve what I want to do?

Comments

#1

i have never used simplenews, but what i think you're essentially asking is for a token to be exposed that you could use like this:

[easylogin-url]?destination=simplenewsurl

interesting. i'll have a think and let you know in the next few days.

#2

great stuff!
Simplenews requires the use of the Token module so that should help.
FYI I'm really only using simplenews as a way of emailing all my users to inform them of a new page/node because they sometimes need a little prodding...

#3

Title:integration with simplenews» expose a token for login url for use elsewhere

i unfortunately don't have time to do this right now, but patches welcome :)

#4

Status:active» postponed

#5

Understood and thank you.
I'll explore to the best of my ability in the meantime.

#6

simplenews doesn't use token by the looks of it. so original post is impossible.

however, exposing a url is still a possibility as i want to allow the admin to cucstomise the email that is sent out re: the new url.

#7

Very sorry, I must have mistakenly read taxonomy as token.

Do you have any thoughts how to expose a URL that an admin can paste into a newletter that would automatically log recipients in?

#8

you need simplenews to utilise tokens for their mails. it'll be a good thing actually!

maybe there's already an issue in the queue for simplenews which you can look for, if not create one. there may already be a patch for it.

#9

Seems like I'm not alone on this one:
Simplenews Tokens

Once tokens is integrated, how would i go about doing what i was originally intending to do?

#10

you could submit a patch for me to utilise tokens in easylogin or wait until i get around to doing it! so...patches welcome!

#11

I'm not sure how to ask simplenews to expose a token or to patch it.

They have tokens/variables which are:
!site (the name of your website)
!uri (a link to your homepage)
!uri_brief (homepage link without the http://)
!date (today's date)
!login_uri (link to login page)
!confirm_subscribe_url (subscription confirmation link)
!confirm_unsubscribe_url (unsubscription link)
!newsletter_url (link to this newsletter issue)
!newsletter_name (name of this newsletter series)

Do i simply ask them to add something like !easylogin_uri (pulling the url from your module?)

#12

Status:postponed» closed (won't fix)

as stated above, simplenews needs to use tokens, otherwise you can't do it. !foo are not tokens.

as a solution to your problem, if you want them to be logged in when they visit a page, how about increasing the session cookie lifetime?

as for the issue, i'm setting this to a won't fix, because, other than this usecase, there's no need for it.

#13

I understand and I'll try to find some other means to do this.

FYI this usecase (or the ability to send a link to a page that automatically logs a user in) is quite popular and your module is half the battle... check out the thread around autologin

For the time being I have asked my users to bookmark your easylogin links in the effort to have them visit more frequently.

#14

I would like to implement autologin to my newsletters too. I have searched a lot of different solutions.

There is http://drupal.org/project/fastlogin for D5 with the help of http://drupal.org/project/loginticket

There is http://drupal.org/project/easylogin that creates a personal login url for every drupal user.

This sound a good way to do the autologin and not sending username/password as plaintext and use autologin -project. I would like to help, but until a client will pay for the development this is just a POC.

Own edit:
I had a bit of extra time yesterday and implemented easylogin hash to simplenews newsletters.
simplenews.module (line 2099)

add uuid query

function simplenews_mail_tokens($subscription, $context, $language) {
  $uuid = '';
  $uuid = db_result(db_query("SELECT url FROM {easylogin_urls}
JOIN {simplenews_subscriptions}
WHERE easylogin_urls.uid = simplenews_subscriptions.uid 
AND simplenews_subscriptions.uid ='%s'", $subscription->uid));

and somewhere near line (2130)

  $vars['!newsletter_name'] = $name;
  $vars['!easylogin'] = url('easylogin/'.$uuid, array('absolute' => TRUE, 'language' => $language));

So now in newsletter you may add a !easylogin token to allow automatical login for people.

#15

I wanted to be able to insert the easylogin url into emails sent out by the Rules module so I created a patch. This is my first attempt at creating a patch so I apologize if it's not correct.

AttachmentSize
easylogin_url_token.patch 979 bytes

#16

Status:closed (won't fix)» needs review

#17

if a few test this, i'll commit.

#18

error patching 6.x-1.2 or 6.x-1.x-dev tar.gz (9.67 KB) 2010-Jul-11

sudo patch < easylogin_url_token.patch
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.

#19

anyway copy-pasting the patch code (aka manual patch !) works and expose the token !

#20

This is exactly what I needed. I found a bug in #15 patch, the hash in the URL was being duplicated, the below code fixes it. Sorry I didn't have a chance to roll a patch. Just place this in easylogin.module:

/**
* Implementation of hook_token_values().
*/
function easylogin_token_values($type, $object=NULL) {
  if ($type == 'user') {
    $user = $object;
    $tokens['easylogin_url'] = $user->easylogin_url;
    return $tokens;
  }
}

/**
* Implementation of hook_token_list().
*/
function easylogin_token_list($type = 'all') {
  if ($type == 'user' || $type == 'all') {
    $tokens['user']['easylogin_url'] = t("The user's easy login url");
    return $tokens;
  }
}

#21

nice going everyone! sorry, but i'm abandoning this module - and drupal in general - as i've seen the light!