1
- import { useSignIn } from "@clerk/clerk-expo" ;
1
+ import { useSignUp , useSignIn } from "@clerk/clerk-expo" ;
2
2
import React from "react" ;
3
3
import { Button , View } from "react-native" ;
4
4
5
5
import * as AuthSession from "expo-auth-session" ;
6
6
7
7
const SignInWithOAuth = ( ) => {
8
8
const { isLoaded, signIn, setSession } = useSignIn ( ) ;
9
-
9
+ const { signUp } = useSignUp ( ) ;
10
10
if ( ! isLoaded ) return null ;
11
11
12
12
const handleSignInWithDiscordPress = async ( ) => {
@@ -32,7 +32,7 @@ const SignInWithOAuth = () => {
32
32
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
33
// @ts -ignore
34
34
const { type, params } = result || { } ;
35
- console . log ;
35
+
36
36
if ( type !== "success" ) {
37
37
throw "Something went wrong during the OAuth flow. Try again." ;
38
38
}
@@ -45,6 +45,23 @@ const SignInWithOAuth = () => {
45
45
const { createdSessionId } = signIn ;
46
46
47
47
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
+ }
48
65
throw "Something went wrong during the Sign in OAuth flow. Please ensure that all sign in requirements are met." ;
49
66
}
50
67
0 commit comments