Skip to content

Commit

Permalink
Fix: change isSecure to variable instead of func (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs committed Mar 27, 2023
1 parent e76898d commit bc12469
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/routes/v2/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ const CSRF_COOKIE_NAME = "isomer-csrf"
const COOKIE_NAME = "isomercms"

class AuthRouter {
constructor({ authService, authenticationMiddleware, apiLogger, rateLimiter }) {
constructor({
authService,
authenticationMiddleware,
apiLogger,
rateLimiter,
}) {
this.authService = authService
this.authenticationMiddleware = authenticationMiddleware
this.apiLogger = apiLogger
Expand Down Expand Up @@ -46,7 +51,7 @@ class AuthRouter {
const cookieSettings = {
expires: csrfTokenExpiry,
httpOnly: true,
secure: isSecure(),
secure: isSecure,
}
res.cookie(CSRF_COOKIE_NAME, cookieToken, cookieSettings)
return res.redirect(redirectUrl)
Expand Down
4 changes: 1 addition & 3 deletions src/utils/auth-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ const { config } = require("@config/config")

const NODE_ENV = config.get("env")

function isSecure() {
return NODE_ENV !== "dev" && NODE_ENV !== "test"
}
const isSecure = NODE_ENV !== "dev" && NODE_ENV !== "test"

module.exports = {
isSecure,
Expand Down

0 comments on commit bc12469

Please sign in to comment.