2020-02-21
Firebase AuthenticationユーザーのdisplayNameは、Firestore rules上ではnameとして定義される
Firebase Authenticationユーザーを、次のように登録したとします。
import * as Firebase from 'firebase'
const auth = Firebase.auth()
const email = someEmail
const password = somePassword
try {
const credential = await auth.createUserWithEmailAndPassword(email, password)
const user = credential.user
if (user === null) {
throw new Error(
`creating user for authentication was success, but nobody is logging in. something wrong! credential: ${credential}`
)
}
await user.updateProfile({ displayName: 'Haskell' }) // !
await user.sendEmailVerification()
} catch (e) {
if (e instanceof Error && /The email address is already in use by another account./.test(e.message)) {
throw new Error(`メールアドレス「${account.email}」は既に使用されています。`)
}
throw new Error(e)
}
…