"User not found" error when invited Patient logs i...
# support
s
Hi all, Invited Practitioner users log in successfully but Patient users do not. I thought this may have something to do with our local config so I just tried from a fresh install and new DB and still the same issue: 1. Install from scratch: https://www.medplum.com/docs/self-hosting/install-from-scratch 2. Register a new user and project from the medplum UI flow 3. As new user: Admin > Project > Users > Invite new user Role = Patient ✅ Send email ✅ Project scoped 4. Signout, follow link in E-mail to set Patient password - all works 5. Click follow-on to log in, enter credentials Login > "Error: User not found" I then added the access policy below, repeated the process inviting a new patient and assigned the access policy but still the same error https://www.medplum.com/docs/access/access-policies#patient-access The User and ProjectMembership and Patient resources are all there and the email addresses are verified and users are associated with the correct project ID. I also tried configuring Project.sites.domains[localhost] in case it can't associate the project with the user. Is there anything I'm missing here? Any help would be great thanks!
f
Hi, @simonj , is this logging in to your own app, or your self hosted version of app.medplum.com? can you confirm whether or not a clientId or projectId is being sent in the payload of the
.../auth/login
POST?
s
Hi @finnbergquist yep that's correct - this is all self hosted on my localhost. There is no clientId or projectId in the payload of the login POST In
packages/server/src/oauth/utils.ts
I can see for
user = await getUserByEmail(request.email, request.projectId);
request.projectId is null It's also null for the Practitioner login but it still finds the user
Sorry @finnbergquist just corrected - was
getUserByEmail
not external ID
Ahhh so I just found the
signin?project=10e36fb4-5217-4576-a43f-17b0ae1183d2
param in the app code and it works 🎉
Ahh it's in the docs too I just didn't think to look there - the error message threw me https://www.medplum.com/docs/app/sign-in-page#signing-in-as-a-patient
Sorry for the runaround - will mark as solved
f
Yea, the reason for this is because your Practitioner is a server scoped User. For a project scoped user, either a projectId or clientId need to be passed into
.../login
You are correct that one way to do this is adding
?project=id
in the url params You can also do this by adding clientId to the MedplumClient instantiation in the app.
Copy code
const medplum = new MedplumClient({
  onUnauthenticated: () => (window.location.href = '/'),
///...
  clientId: import.meta.env?.MEDPLUM_CLIENT_ID,
});
73 Views