예제 #1
0
        public Account CreateAccount(string userName, string password, string email, ClientBoxLevel boxLevel = ClientBoxLevel.Cataclysm,
                                     ClientLocale locale = ClientLocale.English)
        {
            Contract.Requires(!string.IsNullOrEmpty(userName));
            Contract.Requires(userName.Length >= Constants.Accounts.MinNameLength);
            Contract.Requires(userName.Length <= Constants.Accounts.MaxNameLength);
            Contract.Requires(!string.IsNullOrEmpty(password));
            Contract.Requires(password.Length >= Constants.Accounts.MinPasswordLength);
            Contract.Requires(password.Length <= Constants.Accounts.MaxPasswordLength);
            Contract.Requires(!string.IsNullOrEmpty(email));
            Contract.Ensures(Contract.Result <Account>() != null);

            var pw   = CreatePassword(userName, password);
            var sha1 = pw.SHA1Password.GetBytes();

            Contract.Assume(sha1.Length == Password.SHA1Length);
            var sha256 = pw.SHA256Password.GetBytes();

            Contract.Assume(sha256.Length == Password.SHA256Length);

            var rec = new AccountRecord(userName, email, sha1, sha256, boxLevel, locale);

            rec.Create();

            var acc = new Account(rec);

            AddAccount(acc);
            return(acc);
        }
예제 #2
0
        public void CreateAccount(string accountName, string password, string emailAddress, ClientLocale locale, ClientBoxLevel boxLevel)
        {
            if (accountName.Length < AccountManager.MinNameLength || accountName.Length > AccountManager.MaxNameLength)
                throw new ArgumentException();

            if (password.Length < AccountManager.MinPasswordLength || password.Length > AccountManager.MaxPasswordLength)
                throw new ArgumentException();

            AccountManager.Instance.CreateAccount(accountName, password, emailAddress, boxLevel, locale);
        }
예제 #3
0
        public void CreateAccount(string accountName, string password, string emailAddress, ClientLocale locale, ClientBoxLevel boxLevel)
        {
            if (accountName.Length < Constants.Accounts.MinNameLength || accountName.Length > Constants.Accounts.MaxNameLength)
                throw new ArgumentException("Account name has an invalid length.");

            if (password.Length < Constants.Accounts.MinPasswordLength || password.Length > Constants.Accounts.MaxPasswordLength)
                throw new ArgumentException("Password has an invalid length.");

            AccountManager.Instance.PostAsync(x => x.CreateAccount(accountName, password, emailAddress, boxLevel, locale));
        }
예제 #4
0
        /// <summary>
        /// Constructs a new AccountRecord object.
        ///
        /// Should be inserted into the database.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="email"></param>
        /// <param name="sha1"></param>
        /// <param name="sha256"></param>
        /// <param name="boxLevel"></param>
        /// <param name="locale"></param>
        public AccountRecord(string name, string email, byte[] sha1, byte[] sha256, ClientBoxLevel boxLevel = ClientBoxLevel.Cataclysm,
                             ClientLocale locale = ClientLocale.English)
        {
            Contract.Requires(!string.IsNullOrEmpty(name));
            Contract.Requires(name.Length >= Constants.Accounts.MinNameLength);
            Contract.Requires(name.Length <= Constants.Accounts.MaxNameLength);
            Contract.Requires(!string.IsNullOrEmpty(email));
            Contract.Requires(sha1 != null);
            Contract.Requires(sha1.Length == Password.SHA1Length);
            Contract.Requires(sha256 != null);
            Contract.Requires(sha256.Length == Password.SHA256Length);

            Name           = name;
            EmailAddress   = email;
            SHA1Password   = sha1;
            SHA256Password = sha256;
            BoxLevel       = boxLevel;
            Locale         = locale;
        }
예제 #5
0
 public void CreateAccount(string accountName, string password, string emailAddress, ClientLocale locale, ClientBoxLevel boxLevel)
 {
     Contract.Requires(!string.IsNullOrEmpty(accountName));
     Contract.Requires(!string.IsNullOrEmpty(password));
     Contract.Requires(!string.IsNullOrEmpty(emailAddress));
 }
예제 #6
0
        public void CreateAccount(string accountName, string password, string emailAddress, ClientLocale locale, ClientBoxLevel boxLevel)
        {
            if (accountName.Length < Constants.Accounts.MinNameLength || accountName.Length > Constants.Accounts.MaxNameLength)
            {
                throw new ArgumentException("Account name has an invalid length.");
            }

            if (password.Length < Constants.Accounts.MinPasswordLength || password.Length > Constants.Accounts.MaxPasswordLength)
            {
                throw new ArgumentException("Password has an invalid length.");
            }

            AccountManager.Instance.PostAsync(x => x.CreateAccount(accountName, password, emailAddress, boxLevel, locale));
        }
예제 #7
0
 public void CreateAccount(string accountName, string password, string emailAddress, ClientLocale locale, ClientBoxLevel boxLevel)
 {
     Contract.Requires(!string.IsNullOrEmpty(accountName));
     Contract.Requires(!string.IsNullOrEmpty(password));
     Contract.Requires(!string.IsNullOrEmpty(emailAddress));
 }