Refactor authentication module
John Jiang
Branch: johnjiang/atlassian-connect-express:auth-code-refactor
Branch: atlassian/atlassian-connect-express:master
Merged
Merged pull request
Merged in auth-code-refactor (pull request #195)
Merged in auth-code-refactor (pull request #195)
Rather than add functions onto an object and referring to the functions via
this
I’ve split it out into normal functions and calling them directly. I then re-export them by specifying the module exports explicitly.I also took out
extractJwtFromRequest
to be outside of theauthenticate
function so it’s a bit easier to comprehend what’s happening. Having functions defined inside functions makes it a bit difficult to understand where the variables are coming from.The point where I want to get to is to be able to refactor this code so that I could call a function that only returns the
VerifiedParams
. My use-case is that I’m usingapollo-server
and I need to verify the request manually. Currently, I have my own modifiedauthentication.js
code that does this but would be great if I could get this inside ACE so I don’t need to maintain my own copy.Since I’m in no rush as I have something working, I want to create smallish PRs so that things are a bit easier to review.