Skip to content

Commit c879947

Browse files
fix: change googleSignin function name for bettter clarity
1 parent 8b5a384 commit c879947

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

android/src/newarch/java/com/credentialsmanager/CredentialsManagerModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class CredentialsManagerModule(
9090
}
9191
}
9292

93-
override fun signInWithGoogle(
93+
override fun signUpWithGoogle(
9494
requestObject: ReadableMap,
9595
promise: Promise,
9696
) {

android/src/oldarch/java/com/credentialsmanager/CredentialsManagerModule.kt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,35 @@ class CredentialsManagerModule(
6262
}
6363

6464
@ReactMethod
65-
fun signInWithSavedCredentials(
66-
requestJson: ReadableMap,
65+
fun signIn(
66+
options: ReadableArray,
67+
params: ReadableMap,
6768
promise: Promise,
6869
) {
69-
val jsonString = requestJson.toString()
7070
coroutineScope.launch {
71-
val data = credentialHandler.getSavedCredentials(jsonString)
72-
promise.resolve(data)
71+
try {
72+
val data = credentialHandler.signIn(options = options, params = params)
73+
promise.resolve(data)
74+
} catch (e: GetCredentialException) {
75+
Log.e("CredentialManager", "Error during sign out", e)
76+
promise.reject("ERROR", e.message.toString())
77+
}
7378
}
7479
}
7580

81+
82+
// @ReactMethod
83+
// fun signInWithSavedCredentials(
84+
// requestJson: ReadableMap,
85+
// promise: Promise,
86+
// ) {
87+
// val jsonString = requestJson.toString()
88+
// coroutineScope.launch {
89+
// val data = credentialHandler.getSavedCredentials(jsonString)
90+
// promise.resolve(data)
91+
// }
92+
// }
93+
7694
@ReactMethod
7795
fun signOut(promise: Promise) {
7896
coroutineScope.launch {
@@ -87,7 +105,7 @@ class CredentialsManagerModule(
87105
}
88106

89107
@ReactMethod
90-
fun signInWithGoogle(
108+
fun signUpWithGoogle(
91109
requestObject: ReadableMap,
92110
promise: Promise,
93111
) {

example/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { View, StyleSheet, Button } from 'react-native';
22
import {
33
signUpWithPasskeys,
44
signUpWithPassword,
5-
signInWithGoogle,
5+
signUpWithGoogle,
66
signOut,
77
signIn,
88
} from 'react-native-credentials-manager';
@@ -109,10 +109,10 @@ export default function App() {
109109
/>
110110

111111
<Button
112-
title="Signin With Google"
112+
title="SignUp With Google"
113113
onPress={async () => {
114114
try {
115-
const credential = await signInWithGoogle({
115+
const credential = await signUpWithGoogle({
116116
serverClientId: WEB_CLIENT_ID,
117117
autoSelectEnabled: true,
118118
});

src/NativeCredentialsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface Spec extends TurboModule {
5555
googleSignIn?: GoogleSignInParams;
5656
}
5757
): Promise<Credential>;
58-
signInWithGoogle(params: GoogleSignInParams): Promise<GoogleCredential>;
58+
signUpWithGoogle(params: GoogleSignInParams): Promise<GoogleCredential>;
5959
signOut(): Promise<null>;
6060
}
6161

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ export function signIn(
4848
});
4949
}
5050

51-
export function signInWithGoogle(
51+
export function signUpWithGoogle(
5252
params: GoogleSignInParams
5353
): Promise<GoogleCredential> {
54-
return CredentialsManager.signInWithGoogle({
54+
return CredentialsManager.signUpWithGoogle({
5555
...params,
5656
nonce: params.nonce ?? '',
5757
autoSelectEnabled: params.autoSelectEnabled ?? true,

0 commit comments

Comments
 (0)