Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit ed037dd

Browse files
committed
Fixing logout on cross-domain with Api
fix #91
1 parent 263b37f commit ed037dd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

app/scripts/services/auth.coffee

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict'
22

33
class 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

7778
angular.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

Comments
 (0)