-2

I am working on a project and it needs once a user entered his ID he wont be able to see the login page again when he will use the app.

I am not able to understand how to do this logic which I had tried is not working.

can anyone help me on this.This is my link of project on google drive have a look:

https://drive.google.com/open?id=0B51wL8pUai8XSHc0eHFQQ1cxX2M

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
swarnima
  • 69
  • 1
  • 2
  • 9
  • 1
    You should always post code (text) with your question rather than linking to a project, you'll have better success with answers. – Phil Cooper Jun 21 '17 at 12:49

1 Answers1

0

You need to use localStorage in this case, where once you successfully login set your current user to true and on logout set that flag to false.

and over your app.run block you can put a condition.

$rootScope.$on('$stateChangeStart', function (event, toState, toParams,fromState, fromParams) {
       if (toState.name !== 'login') {
            if (!localStorageService.get('currentUser') {
                event.preventDefault();
                $state.go('login');
            }
        } else {
            return false;
        }
}