Skip to content

Commit

Permalink
refactor: removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinaldy Rafli committed Jul 4, 2021
1 parent 9b3234f commit 6b88594
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ export function csrf(opts: CSRFOptions = {}) {
let token: string

req.csrfToken = (): string => {
let newSecret = !options.cookie ? getSecret(req, options.sessionKey, options.cookie, options.middleware) : secret

if (token && newSecret === secret) {
return token
}

if (newSecret === undefined) {
newSecret = tokens.secret()
setSecret(req, res, options.sessionKey, newSecret, options.cookie, options.middleware)
}
const newSecret = !options.cookie ? getSecret(req, options.sessionKey, options.cookie, options.middleware) : secret

token = tokens.create(newSecret)
return token
Expand Down Expand Up @@ -136,10 +127,6 @@ function verifyConfiguration(
return false
}

if (middleware !== 'session' && middleware !== 'cookie') {
return false
}

if (cookie?.signed && !req?.secret) {
return false
}
Expand Down

0 comments on commit 6b88594

Please sign in to comment.