I have a straightforward HTTP service that I access through a service;
module shared {
export interface IAuthService {
isAuthenticated: () => any;
}
export class AuthService implements IAuthService {
static $inject = ['$http'];
constructor(private $http:ng.IHttpService) {
}
isAuthenticated():any {
return this.$http({
method: 'GET',
url: 'http://localhost/auth'
});
}
}
export var app:ng.IModule = app || angular.module('shared', ['ngResource']);
app.service('AuthService', AuthService);
}
And I utilize it in a route resolve;
$stateProvider.state('app', {
url: "/app",
abstract: true,
templateUrl: "app/menu.html",
controller: 'AppController',
resolve: {
authService: 'AuthService',
isAuthenticated: function (authService) {
return authService.isAuthenticated();
}
}
});
The issue is, I use HTTP response codes for the outcome -- if the user is authenticated, I send JSON data back (hence the any return type until I create the class). If not, I return HTTP/403.
This was working fine in JS, maybe by chance, but it appears that in transitioning to typescript, the 403 now completely halts the resolve process and the app just freezes.. Has anyone faced this before? Is there a better approach?
EDIT: I was requested for the generated JS code -- the .state remains the same, the service gets transformed into this;
AuthService.prototype.isAuthenticated = function () {
return this.$http({
method: 'GET',
url: this.ConfigService.apiBaseUri + '/authentication/authenticated',
headers: { 'Authorization': this.ConfigService.sessionId }
});
};