meteorBuzz
meteorBuzz

Reputation: 3200

meteor direct user to a url when session value is set

I am using meteor.js.

How can I direct the client to a url without the click of a button. I am retrieving a url from the server and have this url set in session a variable.

 Session.set('grSignInUrl', result)
//result =  http://www.goodreads.com/oauth/authorize?oauth_token=6mLjmfytrCj695y98S
 window.location = result;

Only when there is a value in this session, I would like the users browser to direct them to this url. How can I achieve this?

Upvotes: 0

Views: 135

Answers (1)

tarmes
tarmes

Reputation: 15442

This is untested, but something like this:

Tracker.autorun = function() {

    var link = Session.get('grSignInUrl');
    if (link) {
        window.location = link;
    }
}

The autorun will be called each time the session variable changes.

Upvotes: 1

Related Questions