Skip to content

Commit

Permalink
fix: per-client tokenName from config files
Browse files Browse the repository at this point in the history
  • Loading branch information
sgarner committed Jun 30, 2021
1 parent 83e4642 commit 6d64602
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/templates/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ export default (ctx, inject) => {

// Config
<% Object.keys(options.clientConfigs).forEach((key) => { %>
const <%= key %>TokenName = '<%= options.clientConfigs[key].tokenName %>' || AUTH_TOKEN_NAME

function <%= key %>GetAuth () {
const token = cookies.get(<%= key %>TokenName)
return token && <%= key %>ClientConfig.validateToken(token) ? AUTH_TYPE + token : ''
}

let <%= key %>ClientConfig
<% if (typeof options.clientConfigs[key] === 'object') { %>
<%= key %>ClientConfig = <%= JSON.stringify(options.clientConfigs[key], null, 2) %>
Expand All @@ -37,7 +30,13 @@ export default (ctx, inject) => {
<%= key %>ClientConfig = <%= key %>ClientConfig(ctx)
<% } %>
const <%= key %>TokenName = <%= key %>ClientConfig.tokenName || AUTH_TOKEN_NAME
function <%= key %>GetAuth () {
const token = cookies.get(<%= key %>TokenName)
return token && <%= key %>ClientConfig.validateToken(token) ? AUTH_TYPE + token : ''
}
const <%= key %>ValidateToken = () => true
if (!<%= key %>ClientConfig.validateToken) {
Expand Down

0 comments on commit 6d64602

Please sign in to comment.