Using auth-http-interceptor to broadcast login-confirmed

817 Views Asked by At

I am using the auth-http-interceptor to broadcast login-confirmed. I have a main.html which is supposed to check whether the user is logged in.

<div class="auth-tripdelta" ng-class="{'wrapper':locationFunction(),'wrapper2': !locationFunction() }">
    <bus-search class="block">
    </bus-search>


    <div class="container">
      <div class="row">

      </div>
    </div>

    <div ui-view></div>


    <newsletter class="visible-sm visible-md visible-lg" ng-show="locationFunction()"></newsletter>

  </div>

and the directive

.directive('authTripdelta',function() {
    return {
      restrict: 'C',
      link: function(scope ,elem, attrs ) {

        scope.$on('event:auth-loginRequired', function() {
          console.log('test1'); // todo modal call above
        });

        scope.$on('event:auth-loginConfirmed', function() {
          console.log('test2');
        });
      }
    }
  });
  <form class="form" name="form" ng-submit="login()" novalidate>
    <div>
      <a class="btn btn-facebook loginButton" href="/authenticate/facebook" >
        <i class="fa fa-facebook"></i> Connect with Facebook
      </a>
      <a class="btn btn-google-plus loginButton" href="/authenticate/google">
        <i class="fa fa-google-plus"></i> Connect with Google+
      </a>
    </div>
  </form>

and the login controller

$scope.login = function() {
      $http.post('/login').success(function() {
        authService.loginConfirmed();
      });
    };

1) However, I do not obtain any of the console.logs. Is there anything wrong with my code?

2) I am right, that the login-confirmed is only fired once and not several times troughout my login session??

0

There are 0 best solutions below