🚩 add provision flow in oauth

Create a flow where if the user logs in with a registered Google account, they are immediately authenticated, but if no
account is found, create a new one.
This commit is contained in:
Rafi Arrafif
2025-08-11 22:54:31 +07:00
parent 7ce0e44389
commit 5d79ffd055
8 changed files with 94 additions and 17 deletions

View File

@ -0,0 +1,22 @@
import { userModel } from "../../user.model";
import {
getUserDataIncludeOptions,
getUserDataOptions,
} from "../../user.types";
export const findUserByProviderIdRepository = async (
providerId: string,
include?: getUserDataOptions["include"]
) => {
return await userModel.findUnique({
where: {
providerId,
},
include: include
? (Object.fromEntries(include.map((key) => [key, true])) as Record<
getUserDataIncludeOptions,
true
>)
: undefined,
});
};