Add 'apps/mobile/' from commit '5fa30f365f21531094cd4d2045042bb4f1370ac3'
git-subtree-dir: apps/mobile git-subtree-mainline:86f8987dffgit-subtree-split:5fa30f365f
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import type { createAuthClient } from "better-auth/react";
|
||||
|
||||
import { finalizeAuthenticatedAccount } from "@/lib/auth-storage";
|
||||
|
||||
type AuthClient = ReturnType<typeof createAuthClient>;
|
||||
|
||||
export async function completeSignInAfterAuth(
|
||||
authClient: AuthClient,
|
||||
input: {
|
||||
apiUrl: string;
|
||||
activeAccountId: string | null;
|
||||
registerAccount: (account: {
|
||||
instanceUrl: string;
|
||||
userId: string;
|
||||
email: string;
|
||||
name: string;
|
||||
}) => Promise<unknown>;
|
||||
},
|
||||
): Promise<boolean> {
|
||||
const session = await authClient.getSession();
|
||||
const user = session.data?.user;
|
||||
if (!user) return false;
|
||||
|
||||
await finalizeAuthenticatedAccount({
|
||||
apiUrl: input.apiUrl,
|
||||
userId: user.id,
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
activeAccountId: input.activeAccountId,
|
||||
registerAccount: input.registerAccount,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user