Skip to content

$scope and event handling #72

Description

@fecabianchi

Hi, i'm having a issue for days and can't figure out a solution here is the deal...

i write an interceptor for any response error

export default function authenticationInterceptor($q, $rootScope) {
  notAuthenticated: 'auth-not-authenticated'
  return {
    responseError: (response) => {
      $rootScope.$broadcast({
        401: notAuthenticated
      }[response.status], response);
      return $q.reject(response);
    }
  }
}

and broadcast the event auth-not-authenticated

i'm setting up the interceptor on app.config.js

and trying to check on app.controller that way

export default class AppController {
  constructor($scope, $rootScope, $state, authentication) {
    notAuthenticated: 'auth-not-authenticated'
    $scope.$on(notAuthenticated, (event) => {
      authentication.logout();
      $state.go('login')
    })

but i can't make this work... any help?
what is the best way to handling authentication and events?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions