I am currently working on an angular application that includes guest functionality. This feature allows me to create a guest account for all unauthorized users in the background. I need to pause routing until the guest account is created and then specify an auth token for all other requests. Currently, I am achieving this by adding a resolve parameter to all routes.
.config(function ($routeProvider) {
var originalWhen = $routeProvider.when;
$routeProvider.when = function (path, route) {
if (path && path.indexOf('sign') === -1) {
route.resolve = route.resolve || {};
route.resolve.userSync = ['User', function (User) {
return User.isSynchronized.promise;
}];
}
return originalWhen.call(this, path, route);
};
});
However, I feel like there might be a better way to accomplish this. Can anyone offer advice on how to handle this situation more effectively?