fnakstad / angular-client-side-auth

One way to implement authentication/authorization in Angular applications
http://angular-client-side-auth.herokuapp.com/
MIT License
1.63k stars 346 forks source link

404 urls raise exception in authorize method of /client/js/services.js #56

Closed gkond closed 10 years ago

gkond commented 10 years ago

Inexistent urls raises exception in authorize method of https://github.com/fnakstad/angular-client-side-auth/blob/master/client/js/services.js#L17 caused by an empty accessLevel parameter.

Try to load any 404 url to see this error in console, for example: http://angular-client-side-auth.herokuapp.com/asdasd

iotaweb commented 10 years ago

I got around this by replacing the 404 and catchall route with a single route, i.e. replace

$routeProvider.when('/404',
    {
        templateUrl: '404',
        access: access.public
    });
$routeProvider.otherwise({redirectTo:'/404'});

with

$routeProvider.otherwise({
    templateUrl: '404',
    access: access.public
});

You don't get the error and the only consequence I can see is that the url on the error page doesn't change to /404 (which is OK for my purposes).

This may not be the only fix - keen to hear other ideas to solve.

fnakstad commented 10 years ago

Thanks iotaweb! That does the trick for me as well. I will be merging the ui-router branch into master within a week, and the entire routing will work a little differently. I'll note this issue down, and make sure that it works without errors with ui-router. If you want to keep using ngRoute I suggest using iotaweb's fix.