Closing a window, then refocusing into first window

I’m trying to write a Meteor program that opens a new window, then once our user logs into this new window I want to close it, and render a new template on the first window.

How can I do this? I currently open a new window with…

Template.launch.events({
 'click #logIn': function(event){
	event.preventDefault();
	var loginURL = baseURL+'oauth2/authorize?response_type=code&client_id='+ client_id +'&redirect_uri='+redirect_uri;
	window.open(loginURL, '_blank');
 }
});

And I handle the redirect with Iron Router using:

Router.route('_oauth/', function(){
   var params = this.params;
   var code = params.query;
   Meteor.call('passCode', code.code);

   this.render('auth');
});

How can I close this window that I open, and then return focus to the fist window for it to render the “auth” template?

I keep answering my own questions shortly after posting them.

FOR ANYONE WITH A SIMILAR QUESTION

The solution uses standard JS functionality on the window variable.
Here is the new code:

Router.route('_oauth/epic/', function(){
   var params = this.params;
   var code = params.query;
   Meteor.call('passCode', code);
   
   window.opener.location = '/test';
   window.close();
});

This works because the new window that is opened stores the parent window as a value, so we can redirect the first window, then close our current.
Window Object Documentation