New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor authentication flow #1411
Conversation
@@ -470,3 +466,13 @@ function auth(data) { | |||
localAuth(client, data.user, data.password, authCallback); | |||
} | |||
} | |||
|
|||
function reverseDnsLookup(ip, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrote this function to be an independent helper. This improves authentication flow (e.g. remember me in webirc most likely did not work before).
const socket = this; | ||
let client; | ||
|
||
const finalInit = () => initializeClient(socket, client, !!data.remember, data.token || null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am now passing token
so that we have a session-like reference to it. This will be required for push notifs and other stuff later.
} else { | ||
init(socket); | ||
socket.emit("auth", {success: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these 2 lines here so that we don't have a big if/else in init
.
@@ -300,13 +300,13 @@ Client.prototype.updateSession = function(token, ip, request) { | |||
const agent = UAParser(request.headers["user-agent"] || ""); | |||
let friendlyAgent = ""; | |||
|
|||
if (agent.browser.name.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes crash if UA is missing.
Refactor authentication flow
This PR is whitespace heavy so review with
?w=1
.