Commit 4fd12f8b authored by Randall Leeds's avatar Randall Leeds

Be defensively promise-y on idp adapter invocation

parent 393fc0d4
...@@ -51,8 +51,8 @@ identityProvider = -> ...@@ -51,8 +51,8 @@ identityProvider = ->
# See https://developer.mozilla.org/en-US/docs/Web/API/navigator.id # See https://developer.mozilla.org/en-US/docs/Web/API/navigator.id
### ###
$get: [ $get: [
'$injector', '$injector', '$q',
($injector) -> ($injector, $q) ->
provider = this provider = this
loggedInUser = undefined loggedInUser = undefined
oncancel = null oncancel = null
...@@ -97,8 +97,8 @@ identityProvider = -> ...@@ -97,8 +97,8 @@ identityProvider = ->
# https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.logout # https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.logout
### ###
logout: -> logout: ->
$injector.invoke(provider.forgetAuthorization, provider) result = $injector.invoke(provider.forgetAuthorization, provider)
.then(invokeCallbacks) $q.when(result).finally(-> onlogout?())
###* ###*
# @ngdoc method # @ngdoc method
...@@ -108,8 +108,8 @@ identityProvider = -> ...@@ -108,8 +108,8 @@ identityProvider = ->
### ###
request: (options={}) -> request: (options={}) ->
{oncancel} = options {oncancel} = options
$injector.invoke(provider.requestAuthorization, provider) result = $injector.invoke(provider.requestAuthorization, provider)
.then(invokeCallbacks, oncancel) $q.when(result).then(invokeCallbacks, oncancel)
###* ###*
# @ngdoc method # @ngdoc method
...@@ -119,8 +119,8 @@ identityProvider = -> ...@@ -119,8 +119,8 @@ identityProvider = ->
### ###
watch: (options) -> watch: (options) ->
{loggedInUser, onlogin, onlogout, onmatch} = options {loggedInUser, onlogin, onlogout, onmatch} = options
$injector.invoke(provider.checkAuthorization, provider) result = $injector.invoke(provider.checkAuthorization, provider)
.then(invokeCallbacks) result.then(invokeCallbacks)
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment