Beispiel #1
0
 static public void Login(string username, string password, bool autoLogin)
 {
     if (KiiUser.IsValidUserName(username) && KiiUser.IsValidPassword(password))
     {
         LoginUI.instance.Wait();
         KiiUser.LogIn(username, password, (KiiUser loginedUser, 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 username 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);
    }
Beispiel #3
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");
     }
 }
 /// <summary>
 /// Set username.
 /// </summary>
 /// <remarks>
 /// Username must be valid.
 /// When called multiple times, it will update existing user name.
 /// </remarks>
 /// <returns>
 /// Itself
 /// </returns>
 /// <param name='userName'>
 /// Username.
 /// </param>
 /// <exception cref='ArgumentException'>
 /// Is thrown when an argument is invalid username.
 /// </exception>
 /// <exception cref='ArgumentNullException'>
 /// Is thrown when an argument is null or empty.
 /// </exception>
 public Builder WithName(string userName)
 {
     if (Utils.IsEmpty(userName))
     {
         throw new ArgumentNullException("userName must not be empty.");
     }
     if (!KiiUser.IsValidUserName(userName))
     {
         throw new ArgumentException(ErrorInfo.KIIUSER_USERNAME_INVALID + userName);
     }
     this.userName = userName;
     return(this);
 }
Beispiel #5
0
 public void Test_0008_isValidUsername_invalid_mark()
 {
     Assert.IsFalse(KiiUser.IsValidUserName("-._\\"));
 }
Beispiel #6
0
 public void Test_0007_isValidUsername_mark()
 {
     Assert.IsTrue(KiiUser.IsValidUserName("-._"));
 }
Beispiel #7
0
 public void Test_0006_isValidUsername_len65()
 {
     Assert.IsFalse(KiiUser.IsValidUserName(NUMBER_50 + NUMBER_10 + "12345"));
 }
Beispiel #8
0
 public void Test_0005_isValidUsername_len64()
 {
     Assert.IsTrue(KiiUser.IsValidUserName(NUMBER_50 + NUMBER_10 + "1234"));
 }
Beispiel #9
0
 public void Test_0004_isValidUsername_len3()
 {
     Assert.IsTrue(KiiUser.IsValidUserName("abc"));
 }
Beispiel #10
0
 public void Test_0003_isValidUsername_len2()
 {
     Assert.IsFalse(KiiUser.IsValidUserName("ab"));
 }
Beispiel #11
0
 public void Test_0002_isValidUsername_empty()
 {
     Assert.IsFalse(KiiUser.IsValidUserName(""));
 }
Beispiel #12
0
 public void Test_0001_isValidUsername_null()
 {
     Assert.IsFalse(KiiUser.IsValidUserName(null));
 }
Beispiel #13
0
 public void Test_0000_isValidUsername_OK()
 {
     Assert.IsTrue(KiiUser.IsValidUserName("kii1234"));
 }