Permalink
Browse files

fix(scripts): sanely handle refreshTokens in the docs script

  • Loading branch information...
philbooth committed Feb 5, 2019
1 parent 0411856 commit 59ab6629e939367b1f460c945abb236465cbdd94
Showing with 13 additions and 7 deletions.
  1. +1 −1 docs/api.md
  2. +12 −6 scripts/write-api-docs.js
@@ -792,7 +792,7 @@ by [fxa-customs-server](https://github.com/mozilla/fxa-customs-server).

#### GET /account/profile

:lock: authenticated with OAuth bearer token, or HAWK-authenticated with session token
:lock: authenticated with OAuth bearer token or HAWK-authenticated with session token
<!--begin-route-get-accountprofile-->
Get the email and locale of a user.

@@ -728,12 +728,7 @@ function marshallAuthentication (authentication) {
}
return 0
}).reduce((summary, token, index) => {
if (token === 'oauthToken') {
summary += 'authenticated with OAuth bearer token'
} else {
summary += `${index === 0 ? '' : ', or '}HAWK-authenticated with ${uncamel(token)}`
}
return summary
return `${summary}${index === 0 ? '' : ' or '}${authenticatedWith(token)}`
}, authentication.optional ? 'Optionally ' : '')
}
}
@@ -751,6 +746,17 @@ function marshallToken (token) {
return token
}

function authenticatedWith (token) {
switch (token) {
case 'oauthToken':
return 'authenticated with OAuth bearer token'
case 'refreshToken':
return 'authenticated with OAuth refresh token'
default:
return `HAWK-authenticated with ${uncamel(token)}`
}
}

function uncamel (string) {
return string.replace(/[A-Z]/g, uppercase => ` ${uppercase.toLowerCase()}`)
}

0 comments on commit 59ab662

Please sign in to comment.