Chimanos
04/17/2023, 8:41 AMThirdPartyEmailPassword
recipe; I'm trying (on the backend) to detect from a user session, if the user is a social or email-password (or both ?) one.
I can see the payload types from getUserInfo
differ :
thirdpartyemailpassword
ts
{
id: string;
timeJoined: number;
email: string;
thirdParty?: {
id: string;
userId: string;
} | undefined;
}
emailpassword
ts
{
id: string;
timeJoined: number;
email: string;
}
thirdparty
ts
{
id: string;
timeJoined: number;
email: string;
thirdParty: {
id: string;
userId: string;
};
}
Is that userInfo.thirdParty != null
supposed to be the legit way to differenciate between both ?
Additionally :
- what should be the behavior of a backend when trying to call updateEmailOrPassword
on a thirdParty signuped account ?
- is a user with both email-password / third party identities supposed to exist ?
Thanksrp_st
04/17/2023, 8:46 AMChimanos
04/17/2023, 8:49 AMrp_st
04/17/2023, 8:51 AMChimanos
04/17/2023, 8:55 AMts
import { User } from 'supertokens-node/recipe/thirdpartyemailpassword/index.js'
Declared as
ts
export declare type User = {
id: string;
timeJoined: number;
email: string;
thirdParty?: {
id: string;
userId: string;
};
};
Could be a type union between
ts
import { User } from 'supertokens-node/recipe/thirdparty/index.js'
and
ts
import { User } from 'supertokens-node/recipe/emailpassword/index.js'
Like so :
ts
export declare type User = ThirdPartyUser | EmailPasswordUser
---
It would unlock great TS features such as type narrowing and type guard. Like :
ts
const userIsThirdParty = (user: ThirdPartyEmailPasswordUser): user is ThirdPartyUser => user.thirdParty != null
rp_st
04/17/2023, 9:00 AM