     if @rootScope.isSuperUser is false
       @location.url path
 
-  removeAuthCookie: ->
-    delete @cookies[@cookieName]
-
   logout: ->
-    @rootScope.isLoggedIn = false
-    @removeAuthCookie()
-    @location.url "/login"
+    @removeAuthentication().then((result) =>
+      if result.loggedOut
+        @rootScope.isLoggedIn = false
+        @location.url "/login"
+    )
 
   googleLogin: ->
     @googlePlus.login().then((authResult) =>

'use strict'

class AuthService
  constructor: (@rootScope, @cookies, @location, @restangular, @googlePlus, @localStorage, @UserViolationsPrefsFcty) ->
    @cookieName = 'HOLMES_AUTH_TOKEN'
    @getAuthenticationFlags()
    @bindEvents()


    )

angular.module('holmesApp')
  .service('AuthSrvc', ($rootScope, $location, Restangular, GooglePlus, $localStorage, UserViolationsPrefsFcty, WebSocketFcty) ->
    return new AuthService($rootScope, $location, Restangular, GooglePlus, $localStorage, UserViolationsPrefsFcty)
  )
