Page MenuHomePhabricator

[keyserver] try registerUser if loginUser fails in keyserver logInResponder
ClosedPublic

Authored by varun on Mar 6 2023, 10:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 28, 10:17 PM
Unknown Object (File)
Mon, Oct 21, 5:59 PM
Unknown Object (File)
Sat, Oct 19, 10:24 AM
Unknown Object (File)
Fri, Oct 18, 5:45 PM
Unknown Object (File)
Sep 30 2024, 1:19 AM
Unknown Object (File)
Sep 30 2024, 1:19 AM
Unknown Object (File)
Sep 30 2024, 1:19 AM
Unknown Object (File)
Sep 30 2024, 1:17 AM
Subscribers

Details

Summary

Changes are as follows:

  1. Modified Identity service to send back "not found" status to caller (it was previously eating this up and closing the connection)
  2. Modified loginUser function in rust-node-addon to propagate the not found error to js if encountered
  3. Wrapped the loginUser call in logInResponder in a try-catch so that if we get back the "not found" error, we attempt a registerUser call instead

Normally I'd make this 3 diffs, but this is urgent

Test Plan

tried logging in with a user in my local MariaDB instance but not in localstack DDB, saw that a new entry was made in DDB upon successful login

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Mar 6 2023, 10:54 PM

Rust looks OK.

keyserver/src/responders/user-responders.js
441 ↗(On Diff #23473)

Generally, I'm not a fan of recognizing errors by comparing message strings, if anybody ever changes that string, this stops working. Ideally we'd want error messages to have unified format, e.g. starting with some error code, like ERR_USER_NOT_FOUND: user not found. Sometimes regex match is sufficient.

But as this diff seems urgent, I'm not blocking on this comment - this is just something worth considering in the future.

ashoat added inline comments.
keyserver/src/responders/user-responders.js
441 ↗(On Diff #23473)

I agree with @bartek, but also don't want to block this diff. @varun, could you create a follow-up task and link it here before landing?

This revision is now accepted and ready to land.Mar 7 2023, 5:52 AM