온보딩 닉네임을 소셜 계정 표시 이름으로 미리 채움
This commit is contained in:
@@ -32,7 +32,14 @@ abstract interface class CredentialProvider {
|
||||
}
|
||||
|
||||
/// 자격증명 한 벌과, 판정에 쓸 그 계정의 이메일.
|
||||
typedef SocialCredential = ({fb.AuthCredential credential, String? email});
|
||||
///
|
||||
/// [name] 은 제공자가 자격증명과 함께만 주는 표시 이름(Apple fullName — 최초 인가 때만). Firebase 가
|
||||
/// 이 값을 계정 이름으로 옮기지 않아, 로그인 직후 우리가 계정에 써 둔다(온보딩 닉네임 기본값).
|
||||
typedef SocialCredential = ({
|
||||
fb.AuthCredential credential,
|
||||
String? email,
|
||||
String? name,
|
||||
});
|
||||
|
||||
/// Google 로그인 — 실 코드 경로.
|
||||
///
|
||||
@@ -67,6 +74,7 @@ final class GoogleSignInProvider
|
||||
return (
|
||||
credential: fb.GoogleAuthProvider.credential(idToken: idToken),
|
||||
email: account.email,
|
||||
name: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,6 +168,10 @@ final class AppleSignInProvider
|
||||
// Apple 은 **최초 인가 때만** 이메일을 준다. 두 번째부터는 null 이라
|
||||
// 「동일 이메일만 연동」 판정을 할 수 없다 — 그때는 통과시킨다.
|
||||
email: credential.email,
|
||||
name: [credential.givenName, credential.familyName]
|
||||
.whereType<String>()
|
||||
.where((part) => part.isNotEmpty)
|
||||
.join(' '),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -179,6 +191,10 @@ final class AppleSignInProvider
|
||||
final result = await fb.FirebaseAuth.instance.signInWithCredential(
|
||||
obtained.credential,
|
||||
);
|
||||
final name = obtained.name;
|
||||
if (name != null && name.isNotEmpty && (result.user?.displayName ?? '').isEmpty) {
|
||||
await result.user?.updateDisplayName(name);
|
||||
}
|
||||
return AuthSucceeded(_toAccount(result.user, provider));
|
||||
} on apple.SignInWithAppleAuthorizationException catch (error) {
|
||||
if (error.code == apple.AuthorizationErrorCode.canceled) {
|
||||
|
||||
Reference in New Issue
Block a user