Пример #1
0
    public IEnumerator UpdateCurrentUserAfterLogin()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e) =>
        {
            Assert.Null(e);

            NCMBUser.CurrentUser.UserName = "******";

            NCMBUser.CurrentUser.SaveAsync((NCMBException ex) =>
            {
                Assert.Null(ex);

                NCMBTestSettings.CallbackFlag = true;
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        // 登録成功の確認
        Assert.True(NCMBTestSettings.CallbackFlag);
        Assert.AreEqual("newUserName", NCMBUser.CurrentUser.UserName);
        Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken());
        Assert.AreEqual("*****@*****.**", NCMBUser.CurrentUser.Email);
    }
Пример #2
0
    public IEnumerator LoginLogoutDeleteUser()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e1) =>
        {
            Assert.Null(e1);
            NCMBTestSettings.CallbackFlag = true;
            NCMBUser.LogOutAsync();
            NCMBUser.LogInAsync("tarou", "tarou", (e2) =>
            {
                Assert.Null(e2);
                NCMBUser user = new NCMBUser();
                user.ObjectId = "anotherObjectId";
                user.DeleteAsync((NCMBException e3) => {
                    Assert.Null(e3);
                    NCMBTestSettings.CallbackFlag = true;
                });
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        Assert.True(NCMBTestSettings.CallbackFlag);
        Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken());
        Assert.AreEqual("tarou", NCMBUser.CurrentUser.UserName);
    }
Пример #3
0
    public IEnumerator LoginLogoutAddUser()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e1) =>
        {
            Assert.Null(e1);
            NCMBTestSettings.CallbackFlag = true;
            NCMBUser.LogOutAsync();
            NCMBUser.LogInAsync("tarou", "tarou", (e2) =>
            {
                Assert.Null(e2);
                NCMBUser user = new NCMBUser();
                user.UserName = "******";
                user.Password = "******";
                user.SignUpAsync((NCMBException e3) => {
                    Assert.Null(e3);
                    NCMBTestSettings.CallbackFlag = true;
                });
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        Assert.True(NCMBTestSettings.CallbackFlag);
        Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken());
        Assert.AreEqual("tarou", NCMBUser.CurrentUser.UserName);
    }
Пример #4
0
    public IEnumerator UpdateOtherUserAfterLogin()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e) =>
        {
            Assert.Null(e);

            NCMBUser user = new NCMBUser();
            user.ObjectId = "anotherObjectId";
            user.UserName = "******";
            user.SaveAsync((NCMBException ex) =>
            {
                Assert.Null(ex);

                NCMBTestSettings.CallbackFlag = true;
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        // 登録成功の確認
        Assert.True(NCMBTestSettings.CallbackFlag);
        Assert.IsNotNull(NCMBUser.CurrentUser);
        Assert.AreEqual("tarou", NCMBUser.CurrentUser.UserName);
        Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken());
    }
 /// <summary>
 /// 非同期処理でユーザ名とパスワードを指定して、ユーザのログインを行います。
 /// </summary>
 /// <returns>ログインしたユーザオブジェクト</returns>
 public static IObservable <NCMBUser> LogInAsync(string name, string password)
 {
     return(Observable.Create <NCMBUser>(observer =>
     {
         var gate = new object();
         var isDisposed = false;
         NCMBUser.LogInAsync(name, password, error =>
         {
             lock (gate)
             {
                 if (isDisposed)
                 {
                     return;
                 }
                 if (error == null)
                 {
                     observer.OnNext(NCMBUser.CurrentUser);
                     observer.OnCompleted();
                 }
                 else
                 {
                     observer.OnError(error);
                 }
             }
         });
         return Disposable.Create(() =>
         {
             lock (gate)
             {
                 isDisposed = true;
             }
         });
     }));
 }
Пример #6
0
    public void OnLogin()
    {
        GameObject.Find("Notation").GetComponent <Text>().text = "";
        if (IfNamePasswordIsFilledIn())
        {
            // ユーザー名とパスワードでログイン
            NCMBUser.LogInAsync(nameInput.text, passwordInput.text, (NCMBException e) => {
                if (e != null)
                {
                    UnityEngine.Debug.Log("ログインに失敗: " + e.ErrorMessage);
                    GameObject.Find("Notation").GetComponent <Text>().text = "ログインに失敗: " + e.ErrorMessage;
                }
                else
                {
                    UnityEngine.Debug.Log("ログインに成功!");
                    GameObject.Find("Notation").GetComponent <Text>().text = "ログインに成功!";
                    Configuration.username = nameInput.text;
#if UNITY_2019_3_OR_NEWER
                    SceneManager.LoadScene("title");
#else
                    Application.LoadLevel("title");
#endif
                }
            });
        }
    }
Пример #7
0
    public IEnumerator FetchAsyncAuthenticationError()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e) => {
            Assert.Null(e);

            NCMBUser.CurrentUser.SessionToken = "invalidToken";
            NCMBUser.CurrentUser._currentOperations.Clear();

            NCMBPush push = new NCMBPush();
            push.ObjectId = "pushDummyObjectId";

            push.FetchAsync((NCMBException ex) =>
            {
                Assert.NotNull(ex);
                Assert.AreEqual("E401001", ex.ErrorCode);
                Assert.AreEqual("Authentication error by header incorrect.", ex.ErrorMessage);
                NCMBTestSettings.CallbackFlag = true;
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        // 登録成功の確認
        Assert.True(NCMBTestSettings.CallbackFlag);
    }
Пример #8
0
    public IEnumerator FetchAsyncDataNotAvailable()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e) => {
            Assert.Null(e);

            NCMBUser.CurrentUser.SessionToken = "invalidToken";
            NCMBUser.CurrentUser._currentOperations.Clear();

            NCMBRole exampleRole = new NCMBRole("exampleRole");
            exampleRole.ObjectId = "roleInvalidObjectId";

            exampleRole.FetchAsync((NCMBException ex) =>
            {
                Assert.NotNull(ex);
                Assert.AreEqual("E404001", ex.ErrorCode);
                Assert.AreEqual("No data available.", ex.ErrorMessage);
                NCMBTestSettings.CallbackFlag = true;
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        // 登録成功の確認
        Assert.True(NCMBTestSettings.CallbackFlag);
    }
Пример #9
0
    public IEnumerator SignUpUseCurrentUserAfterLogin()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e) =>
        {
            Assert.Null(e);

            NCMBUser.CurrentUser.ObjectId = null;
            NCMBUser.CurrentUser.UserName = "******";
            NCMBUser.CurrentUser.Password = "******";

            // 会員登録
            NCMBUser.CurrentUser.SignUpAsync((NCMBException ex) => {
                Assert.Null(ex);
                NCMBTestSettings.CallbackFlag = true;
            });
        });

        yield return(NCMBTestSettings.AwaitAsync());

        // 登録成功の確認
        Assert.True(NCMBTestSettings.CallbackFlag);
        Assert.AreEqual("testuser", NCMBUser.CurrentUser.UserName);
        Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken());
    }
Пример #10
0
        public IEnumerator LogInCoroutine(string userName, string password, Action <CommunicationResult> communicationCallback)
        {
            bool isConnecting      = true;
            CommunicationResult cr = new CommunicationResult();

            NCMBUser.LogInAsync(userName, password, (NCMBException e) =>
            {
                if (e != null)
                {
                    cr.ErroMessage = e.ErrorMessage;
                    cr.ErrorCode   = e.ErrorCode;
                    cr.IsSuccess   = false;
                }
                else
                {
                    cr.IsSuccess = true;
                }

                isConnecting = false;
            });

            while (isConnecting)
            {
                yield return(null);
            }

            if (communicationCallback != null)
            {
                communicationCallback(cr);
            }
        }
Пример #11
0
    // ログイン
    public void OnClick_Login()
    {
        // ユーザー名とパスワードでログイン
        NCMBUser.LogInAsync(
            GameObject.Find("Text_UserName").GetComponent <Text>().text,
            GameObject.Find("Text_Password").GetComponent <Text>().text,
            (NCMBException e) =>
        {
            if (e != null)
            {
                GameObject.Find("Text_Log").GetComponent <Text>().text = string.Format("ログインに失敗しました。\n{0}", e.ErrorMessage);
            }
            else
            {
                GameObject.Find("Text_Log").GetComponent <Text>().text = "ログインに成功しました。";

                // ランキング用オブジェクト生成
                GameObject QuickRankingObj = new GameObject("QuickRanking");
                QuickRankingObj.tag        = "QuickRanking";
                QuickRankingObj.AddComponent <QuickRanking>();

                // ランキング用オブジェクト引き継ぎ
                DontDestroyOnLoad(QuickRankingObj);

                // メインに遷移
                SceneManager.LoadScene(Define.GAME_MAIN);
            }
        });
    }
Пример #12
0
    public void Login()
    {
        print(UserName.text);
        print(PassWord.text);

        //NCMBUserのインスタンス作成
        NCMBUser user = new NCMBUser();
        // オブジェクトからTextコンポーネントを取得
        Text debug_text = Debug_Text.GetComponent <Text>();

        // ユーザー名とパスワードでログイン
        NCMBUser.LogInAsync(UserName.text, PassWord.text, (NCMBException e) => {
            if (e != null)
            {
                UnityEngine.Debug.Log("ログインに失敗: " + e.ErrorMessage);
                debug_text.text = "ログインに失敗: " + e.ErrorMessage;
            }
            else
            {
                UnityEngine.Debug.Log("ログインに成功!");
                // テキストの表示を入れ替える
                debug_text.text = "ログインに成功";
                //LogOutの部分は移動d先のScene名
                Application.LoadLevel("LogOut");
            }
        });
    }
Пример #13
0
    public void Login()
    {
        Debug.Log(UserName.text);
        Debug.Log(PassWord.text);

        //NCMBUserのインスタンス作成
        NCMBUser user = new NCMBUser();

        // ユーザー名とパスワードでログイン
        NCMBUser.LogInAsync(UserName.text, PassWord.text, (NCMBException e) => {
            if (e != null)
            {
                UnityEngine.Debug.Log("ログインに失敗: " + e.ErrorMessage);
            }
            else
            {
                UnityEngine.Debug.Log("ログインに成功!");
#if UNITY_2019_3_OR_NEWER
                SceneManager.LoadScene("LogOut");
#else
                Application.LoadLevel("LogOut");
#endif
            }
        });
    }
Пример #14
0
    // ログイン機能
    public static void logIn(string name, string password)
    {
        LogInScript.setMessage("サーバーに接続しています");
        userName = name;

        // これがどうもうまくいかない
        // 非同期処理だから処理終了を待たずに進んじゃう
        // 処理終了を待つwaitの使い方もよくわからない
        // LogInOrNot();
        // if(LogInNow){
        //     Debug.Log("二重ログインだよ");
        //     return;
        // }
        //////

        NCMBUser.LogInAsync(name, password, (NCMBException e) =>
        {
            //接続成功したら
            if (e == null)
            {
                // getData("test");
                getData();

                successConnect = true;
                LogInNow       = true;
                // saveLogInNow();

                LogInScript.setMessage("ログインしました");
                // Debug.Log("ログインしたよ"+userName+":"+HighScore);
                PlayerInformation.setNamePass(name, password);
                PhotonNetwork.playerName = name;
                Debug.Log(PhotonNetwork.player.NickName); //playerの名前を確認
                SceneManager.LoadScene("TopPage");
                return;
            }
            else if (e.ErrorCode == NCMBException.REQUIRED || e.ErrorCode == NCMBException.RELATION_ERROR)
            {
                LogInScript.setMessage("入力が不十分です");
                Debug.Log("未入力です");
            }
            else if (e.ErrorCode == NCMBException.INCORRECT_PASSWORD)
            {
                LogInScript.setMessage("ユーザー名またはパスワードが間違っています");
                Debug.Log("ユーザー名またはパスワードが間違っています");
            }
            else if (e.ErrorCode == "408")
            {
                LogInScript.setMessage("サーバーとの接続が切断されました");
                Debug.Log("タイムアウト");
            }
            else
            {
                successConnect = false;
                LogInScript.setMessage(e.ErrorCode + ":" + e.Message);
                Debug.Log(e.ErrorCode + ":" + e.Message);
                return;
            }
        });
    }
Пример #15
0
    // mobile backendに接続してログイン

    public void logIn(string id, string pw)
    {
        NCMBUser.LogInAsync(id, pw, (NCMBException e) => {
            // 接続成功したら
            if (e == null)
            {
                currentPlayerName = id;
            }
        });
    }
 public void LoginOrSignUp()
 {
     if (user.text.Length > 0 && password.text.Length > 0)
     {
         if (IsEmail(user.text))
         {
             NCMBUser.LogInWithMailAddressAsync(user.text, password.text, (NCMBException e) => {
                 if (e != null)
                 {
                     if (e.ErrorCode.CompareTo("E400003") == 0)
                     {
                         SignUp();
                     }
                     else
                     {
                         Debug.Log("ログインに失敗: " + e.ErrorMessage);
                     }
                 }
                 else
                 {
                     isLogedIn = true;
                     Debug.Log("ログインに成功!");
                 }
                 SetActive();
             });
         }
         else
         {
             // ユーザー名とパスワードでログイン
             NCMBUser.LogInAsync(user.text, password.text, (NCMBException e) => {
                 if (e != null)
                 {
                     if (e.ErrorCode.CompareTo("E400003") == 0)
                     {
                         SignUp();
                     }
                     else
                     {
                         Debug.Log("ログインに失敗: " + e.ErrorMessage);
                     }
                 }
                 else
                 {
                     isLogedIn = true;
                     Debug.Log("ログインに成功!");
                 }
                 SetActive();
             });
         }
     }
 }
Пример #17
0
 public void Login()
 {
     // ユーザー名とパスワードでログイン
     NCMBUser.LogInAsync("Yamada Tarou", "password", (NCMBException e) => {
         if (e != null)
         {
             UnityEngine.Debug.Log("ログインに失敗: " + e.ErrorMessage);
         }
         else
         {
             UnityEngine.Debug.Log("ログインに成功!");
         }
     });
 }
    // mobile backendに接続してログイン ------------------------

    public void logIn(string id, string pw)
    {
        NCMBUser.LogInAsync(id, pw, (NCMBException e) => {
            // 接続成功したら
            if (e == null)
            {
                currentPlayerName = id;
                Debug.Log("ログインしました!");

                //currentPlayerNameをキーにデータを引っ張ってくる
                initializePlayerInfo(NCMBUser.CurrentUser.ObjectId);
            }
        });
    }
Пример #19
0
    // mobile backendに接続してログイン ------------------------

    public void LogIn(string id, string pw, Action callback)
    {
        NCMBUser.LogInAsync(id, pw, (NCMBException e) =>
        {
            // 接続成功したら
            if (e == null)
            {
                currentPlayerName = id;
                if (callback != null)
                {
                    callback();
                }
            }
        });
    }
Пример #20
0
    public IEnumerator LogInAsync()
    {
        // テストデータ作成
        NCMBUser.LogInAsync("tarou", "tarou", (e) => {
            Assert.Null(e);
            NCMBTestSettings.CallbackFlag = true;
        });

        yield return(NCMBTestSettings.AwaitAsync());

        // 登録成功の確認
        Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken());
        Assert.AreEqual("tarou", NCMBUser.CurrentUser.UserName);
        Assert.True(NCMBTestSettings.CallbackFlag);
    }
Пример #21
0
 public void LogIn(string userName, string password)
 {
     NCMBUser.LogInAsync(userName, password, (NCMBException e) =>
     {
         if (e != null)
         {
             Debug.Log("로그인 실패: " + e.ErrorMessage);
         }
         else
         {
             Debug.Log("로그인 성공");
             SetPoint(5);
         }
     });
 }
Пример #22
0
    // mobile backendに接続してログイン ------------------------

    public void logIn(string id, string pw)
    {
        NCMBUser.LogInAsync(id, pw, (NCMBException e) =>
        {
            // 接続成功したら
            if (e == null)
            {
                currentPlayerName = id;
            }
            // 失敗した場合はサインアップを試みる
            else
            {
                signUp(id, pw);
            }
        });
    }
Пример #23
0
    // mobile backendに接続してログイン ------------------------

    public void logIn(string id, string pw)
    {
        //android実機ではなぜか機能しない例外処理
        NCMBUser.LogInAsync(id, pw, (NCMBException e) => {
            // 接続成功したら
            if (e == null)
            {
                currentPlayerName = id;
                Application.LoadLevel("scTitle");
            }
            else
            {
                isError = true;
            }
        });
    }
 /// <summary>
 /// ログインする
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="password"></param>
 void Login(string userId, string password)
 {
     NCMBUser.LogInAsync(userId, password, (NCMBException e) =>
     {
         if (e != null)
         {
             Debug.LogError("Failed to login: "******"Login successfully. User: " + user.UserName);
             InitUserInfo(user);
         }
     });
 }
Пример #25
0
 /// <summary>
 /// mobile backendに接続してログイン
 /// </summary>
 /// <param name="id"></param>
 /// <param name="pw"></param>
 public void LogIn(string id, string pw)
 {
     NCMBUser.LogInAsync(id, pw, (NCMBException e) =>
     {
         if (e != null)
         {
             //接続失敗したら
             Debug.LogError("ログインに失敗: " + e.ErrorMessage);
         }
         else
         {
             //接続成功したら
             currentPlayerName = id;
             Debug.Log(currentPlayerName + " ログインに成功");
         }
     });
 }
Пример #26
0
 void Start()
 {
     ButtonActivation(false);
     // ユーザー名とパスワードでログイン
     NCMBUser.LogInAsync("Yamada Tarou", "password", (NCMBException e) => {
         if (e != null)
         {
             UnityEngine.Debug.Log("ログインに失敗: " + e.ErrorMessage);
         }
         else
         {
             UnityEngine.Debug.Log("ログインに成功!");
             ButtonActivation(true);
             Debug.Log(NCMBUser.CurrentUser.ObjectId);
         }
     });
 }
Пример #27
0
    //ユーザ名変更
    public static void changeName(string newName)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("user");

        query.WhereEqualTo("userName", getUserName());
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            //検索成功したら
            if (e == null)
            {
                //HighScoreのほうの名前も変える
                NCMBQuery <NCMBObject> query2 = new NCMBQuery <NCMBObject>("HighScore");
                query2.WhereEqualTo("userName", getUserName());
                query2.FindAsync((List <NCMBObject> objList2, NCMBException e2) =>
                {
                    if (e2 == null)
                    {
                        objList2[0]["userName"] = newName;
                        objList2[0].SaveAsync();
                    }
                });


                objList[0]["userName"] = newName;

                objList[0].SaveAsync((NCMBException se) =>
                {
                    if (e == null)
                    {
                        NCMBUser.LogInAsync(newName, PlayerInformation.password);
                    }
                });

                userName = newName;
                PlayerInformation.setNamePass(newName, PlayerInformation.password);
                PhotonNetwork.playerName = newName;

                ChangeUserName.setMessage("変更しました");
            }
            else
            {
                ChangeUserName.setMessage("エラー" + e.ErrorCode + ":" + e.Message);
                return;
            }
        });
    }
Пример #28
0
    public void Login()
    {
        print(UserName.text);
        print(PassWord.text);

        // ユーザー名とパスワードでログイン
        NCMBUser.LogInAsync(UserName.text, PassWord.text, (NCMBException e) => {
            if (e != null)
            {
                UnityEngine.Debug.Log("ログインに失敗: " + e.ErrorMessage);
            }
            else
            {
                UnityEngine.Debug.Log("ログインに成功!");
                Application.LoadLevel("LogOut");
            }
        });
    }
Пример #29
0
    public IEnumerator testLogoutAfterSignUp()
    {
        NCMBUser.LogInAsync("testuser1", "123456", (NCMBException e1) => {
            if (e1 != null)
            {
                UITestSettings.CallbackFlag = true;
            }
            else
            {
                NCMBUser.CurrentUser.DeleteAsync((NCMBException e2) => {
                    UITestSettings.CallbackFlag = true;
                });
            }
        });
        yield return(UITestSettings.AwaitAsync());

        var ifUsernameGameObj = GameObject.Find("UserName");
        var ifUsername        = ifUsernameGameObj.GetComponent <InputField>();

        var ifPasswordGameObj = GameObject.Find("Password");
        var ifPassword        = ifPasswordGameObj.GetComponent <InputField>();

        ifUsername.text = "testuser1";
        ifPassword.text = "123456";

        var btnLogInGameObject = GameObject.Find("SignIn");
        var btnLogIn           = btnLogInGameObject.GetComponent <Button>();

        btnLogIn.onClick.Invoke();

        yield return(new WaitForSeconds(3));

        var btnLogOutGameObject = GameObject.Find("LogOutButton");
        var btnLogOut           = btnLogOutGameObject.GetComponent <Button>();

        Assert.NotNull(btnLogOut);

        btnLogOut.onClick.Invoke();
        yield return(new WaitForSeconds(3));

        btnLogInGameObject = GameObject.Find("LogIn");
        btnLogIn           = btnLogInGameObject.GetComponent <Button>();
        Assert.NotNull(btnLogIn);
    }
Пример #30
0
 // ログイン
 public void OnClick_Login()
 {
     // ユーザー名とパスワードでログイン
     NCMBUser.LogInAsync(
         GameObject.Find("Text_UserName").GetComponent <Text>().text,
         GameObject.Find("Text_Password").GetComponent <Text>().text,
         (NCMBException e) =>
     {
         if (e != null)
         {
             GameObject.Find("Text_Log").GetComponent <Text>().text = string.Format("ログインに失敗しました。\n{0}", e.ErrorMessage);
         }
         else
         {
             GameObject.Find("Text_Log").GetComponent <Text>().text = "ログインに成功しました。";
             SceneManager.LoadScene(Define.GAME_LOBY);
         }
     });
 }