Skip to content

Instantly share code, notes, and snippets.

@dcoffey3296
dcoffey3296 / angular-fullstack-redirect.js
Last active September 17, 2019 15:55
Authentication redirect for angular-fullstack yeoman generator
// I figured it out, here are the steps I took to solve this problem. For some reason, Stack Overflow isn't formatting my last 2 code blocks below.
// 1. store the url to return to in a cookie within the '.run()' method of `client/app/app.js`
.run(function ($rootScope, $location, Auth, $cookieStore) {
// Redirect to login if route requires auth and you're not logged in
$rootScope.$on('$stateChangeStart', function (event, next) {
Auth.isLoggedInAsync(function(loggedIn) {
if (next.authenticate && !loggedIn) {
// store the requested url if not logged in