🚩 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:
@ -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,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user