Skip to content

new server not crashed if send bad token#5

Closed
OsirisAnubiz wants to merge 1 commit intoHowProgrammingWorks:masterfrom
OsirisAnubiz:fix-bug
Closed

new server not crashed if send bad token#5
OsirisAnubiz wants to merge 1 commit intoHowProgrammingWorks:masterfrom
OsirisAnubiz:fix-bug

Conversation

@OsirisAnubiz
Copy link
Copy Markdown

Now if you sand token that not contained on Storage, server not crashed.

There are several points of contention.

  1. If Storage did not find a session by key. Pass error to callback or pass undefined?

Now. (pass error)

if (err) {
  callback(err);
  return;
}

Maybe return undefined more correct? It's make Storage more like look on Map.

if (err) {
  callback(null, undefined);
  return;
}
  1. Maybe should drop "getIntsance". Because this method, it only creates a client with a session.

If it was not possible to create a client, then it cannot be passed to the handler, then you need to respond with an empty page.
Now

try {
  const client = await Client.getInstance(req, res);
} catch {
  res.statusCode = INVALID_TOKEN_CODE;
  res.end();
  return;
}

More correct?

const client = new Client(req, res);
try {
  await Session.restore(client)
} catch {
  ???????
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant