Skip to content

Commit

Permalink
Remove strict object expectation of onLoggedIn/Out hook returns
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Hornung committed Mar 26, 2016
1 parent ab96d65 commit af0e69b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/restivus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class @Restivus
token = Accounts._hashLoginToken @request.headers['x-auth-token']
userId: @request.headers['x-user-id']
token: token
onLoggedIn: -> {}
onLoggedOut: -> {}
defaultHeaders:
'Content-Type': 'application/json'
enableCors: true
Expand Down Expand Up @@ -298,8 +296,8 @@ class @Restivus
response = {status: 'success', data: auth}

# Call the login hook with the authenticated user attached
extraData = self._config.onLoggedIn.call(this)
if extraData and _.isObject(extraData) and (not _.isEmpty(extraData))
extraData = self._config.onLoggedIn?.call(this)
if extraData?
_.extend(response.data, {extra: extraData})

response
Expand All @@ -321,8 +319,8 @@ class @Restivus
response = {status: 'success', data: {message: 'You\'ve been logged out!'}}

# Call the logout hook with the authenticated user attached
extraData = self._config.onLoggedOut.call(this)
if extraData and _.isObject(extraData) and (not _.isEmpty(extraData))
extraData = self._config.onLoggedOut?.call(this)
if extraData?
_.extend(response.data, {extra: extraData})

response
Expand Down

0 comments on commit af0e69b

Please sign in to comment.