0

I'm about to create a simple website (to learn Angularjs v1) that displays advertisements and I want to display only 2 pages for the public: 1) page that have the advertisements 2) And a login page When the user logged (the admin) he can see the other pages like createAd.html Any clue please?

Dark_angel
  • 109
  • 1
  • 2
  • 9
  • You might need to look into http://stackoverflow.com/questions/20969835/angularjs-login-and-authentication-in-each-route-and-controller – Hardik Patel May 12 '16 at 09:31

1 Answers1

1

You could store this data in a cookie and read the cookie whether the user is logged in. And when the users logs out, of course destroy the cookie.

Another option would be to store it in a variable in a global service and just have a get in the service to retrieve the value of the cookie.

If using a factory you could simply use:

        factory.getAuthToken = function () {
            return _authToken;
        };

If you use an authentication token.

selten98
  • 821
  • 4
  • 15