0

I'm building my authentication code and I'm using the 401 interception that has been talked about many times on this board. Redirect after user has logged in

My only problem is that I don't like that when you first start the app and you haven't logged in, it will then redirect you from the home screen to login page (you see the home screen for a split second then the login screen). Can I just have the login page be the default page based on whether or not there is an apitoken stored in their cookie OR based on whether I can successfully ping the server with my auth token?.

Thanks!

Community
  • 1
  • 1
avian
  • 1,693
  • 3
  • 20
  • 30

1 Answers1

1

You can do a redirect when the module runs. This will take effect before it displays a page.

app.run( function($location)  {

        if (!apitoken)
            $location.path("/login");
});
Joe F
  • 4,174
  • 1
  • 14
  • 13
Karen Zilles
  • 7,633
  • 3
  • 34
  • 33