Beispiel #1
0
 static public void Signup(string username, string password, string displayName, bool autoLogin)
 {
     //先在客户端检查是否合法
     if (KiiUser.IsValidUserName(username) && KiiUser.IsValidPassword(password) && KiiUser.IsValidDisplayName(displayName))
     {
         KiiUser.Builder userBuilder = KiiUser.BuilderWithName(username);
         KiiUser         user        = userBuilder.Build();
         user.Displayname = displayName;
         LoginUI.instance.Wait();
         user.Register(password, (KiiUser registeredUser, Exception e) =>
         {
             LoginUI.instance.StopWait();
             if (e == null)
             {
                 PlayerPrefs.SetInt("auto login", autoLogin ? 1 : 0);
                 PlayerPrefs.SetString("access token", KiiUser.AccessToken);
                 LoginUI.instance.OnLoginSuccess();
             }
             //处理异常
             else
             {
                 HandlerLoginException(e);
             }
         });
     }
     else
     {
         LoginUI.instance.ShowMessage("Invalid name or password");
     }
 }
Beispiel #2
0
    //入力されたユーザID、パスワードのユーザが存在しなければ新規作成
    public bool RegistUser(string userName, string password)
    {
        if (!KiiUser.IsValidUserName(userName) ||
            !KiiUser.IsValidPassword(password))
        {
            Debug.LogError("Invalid user name or password : "******"Success user regist : " + userName);
        }
        catch (System.Exception exception)
        {
            Debug.Log("Failed user regist : " + userName + " : " + exception);
            _User = null;
            return(false);
        }

        return(true);
    }
        public void Test_0300_Builde_All()
        {
            KiiUser.Builder builder = KiiUser.BuilderWithName("kii1234").WithEmail("*****@*****.**").WithPhone("09011112222");
            KiiUser         user    = builder.Build();

            Assert.AreEqual("kii1234", user.Username);
            Assert.AreEqual("*****@*****.**", user.Email);
            Assert.AreEqual("09011112222", user.Phone);
        }
        public void Test_0502_BuilderWithIdentifier_Email_OK()
        {
            string identifier = "*****@*****.**";

            KiiUser.Builder builder = KiiUser.BuilderWithIdentifier(identifier);

            KiiUser user = builder.Build();

            Assert.IsNull(user.Username);
            Assert.AreEqual(identifier, user.Email);
            Assert.IsNull(user.Phone);
            Assert.IsNull(user.Country);
        }
        public void Test_0501_BuilderWithIdentifier_Phone_OK()
        {
            string identifier = "+819011112222";

            KiiUser.Builder builder = KiiUser.BuilderWithIdentifier(identifier);

            KiiUser user = builder.Build();

            Assert.IsNull(user.Username);
            Assert.IsNull(user.Email);
            Assert.AreEqual(identifier, user.Phone);
            Assert.IsNull(user.Country);
        }
        public void Test_0900_SetName_OK()
        {
            string identifier = "*****@*****.**";
            string username   = "******";

            KiiUser.Builder builder = KiiUser.BuilderWithIdentifier(identifier);

            KiiUser user1 = builder.Build();

            Assert.IsNull(user1.Username);
            Assert.AreEqual(identifier, user1.Email);
            Assert.IsNull(user1.Phone);
            Assert.IsNull(user1.Country);

            builder.SetName(username);

            KiiUser user2 = builder.Build();

            Assert.AreEqual(username, user2.Username);
            Assert.AreEqual(identifier, user2.Email);
            Assert.IsNull(user2.Phone);
            Assert.IsNull(user2.Country);
        }
        public void Test_0400_BuilderWithLocalPhone_OK()
        {
            string phone   = "09011112222";
            string country = "JP";

            KiiUser.Builder builder = KiiUser.BuilderWithLocalPhone(phone, country);

            KiiUser user = builder.Build();

            Assert.IsNull(user.Username);
            Assert.IsNull(user.Email);
            Assert.AreEqual(phone, user.Phone);
            Assert.AreEqual(country, user.Country);
        }
Beispiel #8
0
        public void Test_BuilderWithIdentifier_Email()
        {
            string identifier = "*****@*****.**";

            KiiUser.Builder builder = KiiUser.BuilderWithIdentifier(identifier);

            builder.Build().Register("123456");

            KiiUser user = KiiUser.CurrentUser;

            Assert.IsNull(user.Username);
            Assert.AreEqual(identifier, user.Email);
            Assert.IsNull(user.Phone);
            Assert.IsNull(user.Country);
        }
        public void Test_0700_SetLocalPhone_OK()
        {
            string identifier = "+819011112222";
            string phone      = "09011112222";
            string country    = "JP";

            KiiUser.Builder builder = KiiUser.BuilderWithIdentifier(identifier);

            KiiUser user1 = builder.Build();

            Assert.IsNull(user1.Username);
            Assert.IsNull(user1.Email);
            Assert.AreEqual(identifier, user1.Phone);
            Assert.IsNull(user1.Country);

            builder.SetLocalPhone(phone, country);

            KiiUser user2 = builder.Build();

            Assert.IsNull(user2.Username);
            Assert.IsNull(user2.Email);
            Assert.AreEqual(phone, user2.Phone);
            Assert.AreEqual(country, user2.Country);
        }
        public void Test_0600_SetGlobalPhone_OK()
        {
            string local   = "09011112222";
            string country = "JP";
            string global  = "+819011112222";

            KiiUser.Builder builder = KiiUser.BuilderWithLocalPhone(local, country);

            KiiUser user1 = builder.Build();

            Assert.IsNull(user1.Username);
            Assert.IsNull(user1.Email);
            Assert.AreEqual(local, user1.Phone);
            Assert.AreEqual(country, user1.Country);

            builder.SetGlobalPhone(global);

            KiiUser user2 = builder.Build();

            Assert.IsNull(user2.Username);
            Assert.IsNull(user2.Email);
            Assert.AreEqual(global, user2.Phone);
            Assert.IsNull(user2.Country);
        }
Beispiel #11
0
        public void Test_SetGlobalPhone()
        {
            string identifier = "kii1234";
            string phone      = "+8719011112222";

            KiiUser.Builder builder = KiiUser.BuilderWithIdentifier(identifier);
            builder.SetGlobalPhone(phone);

            builder.Build().Register("123456");

            KiiUser user = KiiUser.CurrentUser;

            Assert.AreEqual(identifier, user.Username);
            Assert.IsNull(user.Email);
            Assert.AreEqual(phone, user.Phone);
            Assert.IsNull(user.Country);
        }
Beispiel #12
0
 public void register()
 {
     //Espacio para que el usuario se registre
     userName = nameregister.value;
     pwd      = passregister.value;
     emailId  = mailregister.value;
     if (userName == "" || pwd == "" || emailId == "")
     {
         faltan.text = "One or more required field(s) are missing.";
     }
     else
     {
         /*userService = sp.BuildUserService ();
          * userService.CreateUser (userName, pwd, emailId, callBackUser);
          * cLabel.SetActive (true);
          * Debug.Log ("El Usuario ha sido creado.");
          * mystats.idplayer = userName;
          * Dictionary <string, object> jsonDoc = new Dictionary <string,object> ();
          * storageService = sp.BuildStorageService ();
          * storageService.FindDocumentById (dbName, collectionName, jsonid, callBack);
          * storageService.InsertJSONDocument(dbName, mystats.idplayer + "myDataBase", json, callBack1);
          */
         mystats.idplayer = userName;
         KiiUser.Builder builder = KiiUser.BuilderWithName(userName);
         builder.WithEmail(emailId);
         KiiUser usr = builder.Build();
         usr.Register(pwd, (KiiUser user, Exception e) =>
         {
             if (e != null)
             {
                 faltan.text = "Password must be between 4 to 50 alphanumeric characters.";
                 Debug.LogError("Signup failed: " + e.ToString());
                 // process error
             }
             else
             {
                 Debug.Log("Signup succeeded.");
                 faltan.text = "Signup succeeded. Signing in...";
                 Save();
                 Application.LoadLevel("PruebaMatchList");
                 // do something with user, it's a valid user now
             }
         });
     }
 }
 public void Test_0200_BuilderWithPhone_OK()
 {
     KiiUser.Builder builder = KiiUser.BuilderWithPhone("+819011112222");
     Assert.AreEqual("+819011112222", builder.Build().Phone);
 }
 public void Test_0100_BuilderWithEmail_OK()
 {
     KiiUser.Builder builder = KiiUser.BuilderWithEmail("*****@*****.**");
     Assert.AreEqual("*****@*****.**", builder.Build().Email);
 }
 public void Test_0000_BuilderWithName_OK()
 {
     KiiUser.Builder builder = KiiUser.BuilderWithName("kii1234");
     Assert.AreEqual("kii1234", builder.Build().Username);
 }