0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Firebase】ウェブサイトで Firebase Authentication を使ってみる

Posted at

ウェブサイトで Firebase Authentication を使ってみる

こちらvue-cliでFirebase Authenticationを使って、ユーザ登録機能の実装したので備忘録として書きます!

1. アプリを Firebase に接続する

  1. vue.jsのログイン認証をFirebase Authenticationを使って構築を参考に、プロジェクト作成〜アプリ登録を行う。

  2. FirebaseのSDKが表示が表示されるので、vueのプロジェクトに貼り付ける(こちら外部jsファイルにして読み込むのが良いっぽい)

2. 新しいユーザーを登録する

ユーザーがフォームに入力したら、ユーザーから提供されたメールアドレスとパスワードを検証し、それらを firebase.auth()createUserWithEmailAndPassword メソッドに渡す

        signUp: function (context, payload) {
            firebase.auth().createUserWithEmailAndPassword(payload.email, payload.password)
                .then(() => {
                    firebase.auth().currentUser.updateProfile({
                    displayName: payload.username,
                    },)
                .then(() => {
                    context.commit('AddToState', payload)
                })
                .then(() => {
                    router.push('/')
                })
                })
                .catch(error => {
                    alert(error.message)
                })
        },

3. 既存のユーザーをログインさせる

こちら実装中・・・

4. 認証状態オブザーバーを設定し、ユーザーデータを取得する

こちら実装中・・・

適宜更新します!

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?