Validate subdomain API in Angularjs -
i have created small angular app have subdomain wildcards. every subdomain account. when going angular app first thing validate whether account exists api call. have created restfull api call validates subdomains don't know have validate in angular. first thing , if not valid should redirected 404 error page.
now first thing doing is
$stateprovider .state('default', { abstract: true, templateurl: core.theme_dir+'modules/core/views/layouts/default.html', resolve: { authenticated: function($q, $location, $auth) { var deferred = $q.defer(); if (!$auth.isauthenticated()) { $location.path('/auth/login'); } else { deferred.resolve(); } return deferred.promise; } } }) .state('minimal', { abstract: true, url: '', templateurl: core.theme_dir+'modules/core/views/layouts/minimal.html' });
at point checking whether user has logged in otherwise redirected login page. before validate subdomain. how can that?
maybe:
app.run(function ($rootscope,$location){ $rootscope.$on('$routechangestart',function(event,next,current){ validate here??? }); });
thanks
one method use factory can injected controllers required. either way shows how can host name , subdomain using $location.
.factory('subdomain', ['$location', function ($location) { var host = $location.host(); if (host.indexof('.') < 0) return null; else return host.split('.')[0]; }])
i'm not sure how rest of app put able provide on validating this.
Comments
Post a Comment