On the page that the user logs in on you can set a sessionStorage
item.
sessionStorage.setItem('login_redirect', window.location.href);
Then once login is done you can redirect them to the page they logged in on using.
window.location.href = sessionStorage.getItem('login_redirect');
A basic guide to dom storage can be found here.