Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 264589d

Browse files
authored
Merge pull request #19 from clerkinc/sign-up-transfer
Create an account instead of requiring the user to resign in
2 parents 03c16b9 + 91df357 commit 264589d

File tree

3 files changed

+20
-77
lines changed

3 files changed

+20
-77
lines changed

apps/expo/src/components/SignInWithOAuth.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useSignIn } from "@clerk/clerk-expo";
1+
import { useSignUp, useSignIn } from "@clerk/clerk-expo";
22
import React from "react";
33
import { Button, View } from "react-native";
44

55
import * as AuthSession from "expo-auth-session";
66

77
const SignInWithOAuth = () => {
88
const { isLoaded, signIn, setSession } = useSignIn();
9-
9+
const { signUp } = useSignUp();
1010
if (!isLoaded) return null;
1111

1212
const handleSignInWithDiscordPress = async () => {
@@ -32,7 +32,7 @@ const SignInWithOAuth = () => {
3232
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3333
// @ts-ignore
3434
const { type, params } = result || {};
35-
console.log;
35+
3636
if (type !== "success") {
3737
throw "Something went wrong during the OAuth flow. Try again.";
3838
}
@@ -45,6 +45,23 @@ const SignInWithOAuth = () => {
4545
const { createdSessionId } = signIn;
4646

4747
if (!createdSessionId) {
48+
if (signIn.firstFactorVerification.status === "transferable") {
49+
console.log("Didn't have an account transferring");
50+
51+
await signUp.create({ transfer: true });
52+
53+
const { rotating_token_nonce: rotatingTokenNonce } = params;
54+
55+
await signUp.reload({ rotatingTokenNonce });
56+
57+
const { createdSessionId } = signUp;
58+
if (!createdSessionId) {
59+
throw "Something went wrong during the Sign up OAuth flow. Please ensure that all sign up requirements are met.";
60+
}
61+
await setSession(createdSessionId);
62+
63+
return;
64+
}
4865
throw "Something went wrong during the Sign in OAuth flow. Please ensure that all sign in requirements are met.";
4966
}
5067

apps/expo/src/components/SignUpWithOAuth.tsx

-72
This file was deleted.

apps/expo/src/screens/signin.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import React from "react";
33
import { View, SafeAreaView } from "react-native";
44

55
import SignInWithOAuth from "../components/SignInWithOAuth";
6-
import SignUpWithOAuth from "../components/SignUpWithOAuth";
76

87
export const SignInSignUpScreen = () => {
98
return (
109
<SafeAreaView className="bg-[#2e026d] bg-gradient-to-b from-[#2e026d] to-[#15162c]">
1110
<View className="h-full w-full p-4">
12-
<SignUpWithOAuth />
1311
<SignInWithOAuth />
1412
</View>
1513
</SafeAreaView>

0 commit comments

Comments
 (0)