11' use strict'
22
33class AuthService
4- constructor : (@rootScope , @cookies , @location , @restangular , @googlePlus , @localStorage , @UserViolationsPrefsFcty ) ->
5- @cookieName = ' HOLMES_AUTH_TOKEN'
4+ constructor : (@rootScope , @location , @restangular , @googlePlus , @localStorage , @UserViolationsPrefsFcty ) ->
65 @ getAuthenticationFlags ()
76 @ bindEvents ()
87
@@ -17,6 +16,9 @@ class AuthService
1716 getAuthentication : ->
1817 @restangular .one (' authenticate' ).get ()
1918
19+ removeAuthentication : ->
20+ @restangular .one (' authenticate' ).remove ()
21+
2022 authenticate : (data ) ->
2123 @restangular .all (' authenticate' ).post (data)
2224
@@ -39,13 +41,12 @@ class AuthService
3941 if @rootScope .isSuperUser is false
4042 @location .url path
4143
42- removeAuthCookie : ->
43- delete @cookies [@cookieName ]
44-
4544 logout : ->
46- @rootScope .isLoggedIn = false
47- @ removeAuthCookie ()
48- @location .url " /login"
45+ @ removeAuthentication ().then ((result ) =>
46+ if result .loggedOut
47+ @rootScope .isLoggedIn = false
48+ @location .url " /login"
49+ )
4950
5051 googleLogin : ->
5152 @googlePlus .login ().then ((authResult ) =>
@@ -75,6 +76,6 @@ class AuthService
7576 )
7677
7778angular .module (' holmesApp' )
78- .service (' AuthSrvc' , ($rootScope , $cookies , $ location , Restangular , GooglePlus , $localStorage , UserViolationsPrefsFcty , WebSocketFcty ) ->
79- return new AuthService ($rootScope, $cookies, $ location, Restangular, GooglePlus, $localStorage, UserViolationsPrefsFcty)
79+ .service (' AuthSrvc' , ($rootScope , $location , Restangular , GooglePlus , $localStorage , UserViolationsPrefsFcty , WebSocketFcty ) ->
80+ return new AuthService ($rootScope, $location, Restangular, GooglePlus, $localStorage, UserViolationsPrefsFcty)
8081 )
0 commit comments