-
Notifications
You must be signed in to change notification settings - Fork 4
Description
this conversation from #211:
@ahdinosaur keen on your thoughts on this, looking at this problem again today...
so at the moment this is a after-create hook on agents, which gives us the problem that this hook fires before the credentials service has finished creating a users credential - meaning we can't tell if this is an invited user (through MemberInvites) or a user signing up by themselves.
so I thought aha! why not just a hook on credentials rather than agents? but after experimenting with that, i learned that currently the flow is:
registering creates a credential, which then creates an agent if there is no agent data in the before hook
creating that agent then creates a credential in the after hook (this credential has no data associated with it apart from agentId, i.e. no password or Oauth id)
so hooking onto credentials for email invites ends up sending 2 invites, which is bad, and would also send an invite for any other credential created for a user, also bad.
i'm wondering now whether to prevent that second credential creation... but i can imagine situations where we want creating an agent to also create a credential. and that kinda strikes at the point as i'm thinking now - perhaps we should BE creating agents which then create credentials, rather than the other way around? MemberInvites works this way - is there a reason registering doesn't?