LoginSignup
16
13

More than 3 years have passed since last update.

firebase authで詰まった

Last updated at Posted at 2019-03-31
auth.js
$('#signUp').on("click",function(){
      // メールアドレス・パスワードを取得
    var email = $("#email").val();
    var password = $("#password").val();
    var userName = $("#displayName").val();

    // 新規ユーザーを登録
    firebase.auth().createUserWithEmailAndPassword(email, password).then((user)=>{

        user.updateProfile({
        displayName:userName
        })
    });
  });

これがダメで

auth.js
$('#signUp').on("click",function(){
      // メールアドレス・パスワードを取得
    var email = $("#email").val();
    var password = $("#password").val();
    var userName = $("#displayName").val();

    // 新規ユーザーを登録
    firebase.auth().createUserWithEmailAndPassword(email, password).then((user)=>{
        var user = firebase.auth().currentUser;
        user.updateProfile({
        displayName:userName
        })
    });
  });

ちゃんとuserを定義し直さないとダメだった

↑は忘れてください、コメントで指摘してくださった通り

auth.js
$('#signUp').on("click",function(){
      // メールアドレス・パスワードを取得
    var email = $("#email").val();
    var password = $("#password").val();
    var userName = $("#displayName").val();

    // 新規ユーザーを登録
    firebase.auth().createUserWithEmailAndPassword(email, password).then((result)=>{
        result.user.updateProfile({
        displayName:userName
        })
    });
  });

ですね

16
13
1

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
16
13