First of all, thanks for this awesome guide. It is a super helpful and saved me a lot of time. Second, I have a question - I need to make sure I get the overall pattern right.
Assuming I am writing a web serverless app with both “local” users (stored & authorized by a Cognito User Pool), and facebook users, the overall structure is like this:
- New local users register by
- Existing local users login by
- Facebook users register/login (is the same for them) by
Auth.federatedSignIn. Arguments for this function (token & user attributes) are received from FB by the
Is this correct? What is confusing me a little bit is that with this setup, the
Auth.currentAuthenticatedUser function can return two completely different things: either a
CognitoUser object for local users or just a plain map of user attributes and I have found no official, documented way of distinguishing these two case. Of course, I can remember what auth method user used or I can check the class of the returned value (or presence of some keys, whatever), but that feels a bit odd. So, is the above pattern correct? Or am I missing something?