Exemplo n.º 1
0
 public static UserAccount UserAccount(Coordinates focusCoordinates = null)
 {
     return new UserAccount
     {
         FocusCoordinates = focusCoordinates ?? new Coordinates()
     };
 }
Exemplo n.º 2
0
        public bool CreateUserAccount(string username, string emailAddress, string password, string confirmPassword, int empireID, Coordinates focus, out UserAccount user, out string errors)
        {
            string validatedErrors;
            if(this.Validate(username, emailAddress, password, confirmPassword, out validatedErrors))
            {
                var created = DateTime.UtcNow;
                created = created.AddMilliseconds(-created.Millisecond); // strip off milliseconds so SQL doesn't do it for us
                var salt = _cryptographyManager.CreateSalt();
                var hash = _cryptographyManager.CreateHash(created, password, salt);

                var securityUser = new SecurityUserAccount
                {
                    CreateTS = created,
                    EmailAddress = emailAddress,
                    PasswordSalt = salt,
                    PasswordHash = hash,
                    Username = username
                };

                _users.CreateUserAccount(securityUser, empireID, focus);
                user = _users.GetUserByUsername(username);
                errors = null;
                return true;
            }
            else
            {
                errors = validatedErrors;
                user = null;
                return false;
            }
        }
Exemplo n.º 3
0
        public LocalAreaView(Coordinates focusCoordinates, ScreenSize screenSize)
        {
            if (focusCoordinates == null) throw new ArgumentNullException("focusCoordinates");
            if (screenSize == null) throw new ArgumentNullException("screenSize");

            FocusCoordinates = focusCoordinates;
            ScreenSize = screenSize;
        }
Exemplo n.º 4
0
 public static SolarSystem SolarSystem(int id = 5, string name = null, Coordinates coordinates = null)
 {
     return new SolarSystem
     {
         SolarSystemID = id,
         Name = name ?? Guid.NewGuid().ToString(),
         Coordinates = coordinates ?? new Coordinates()
     };
 }
Exemplo n.º 5
0
        public void CreateUserAccount(SecurityUserAccount securityUser, int empireID, Coordinates coordinates)
        {
            if (securityUser == null) throw new ArgumentNullException("securityUser");

            using (var cmd = this.SessionManager.GetCurrentUnitOfWork().CreateCommand("INSERT INTO UserAccounts (Username, EmailAddress, PasswordHash, PasswordSalt, CreateTS, EmpireID, X, Y, Z) VALUES (@Username, @EmailAddress, @PasswordHash, @PasswordSalt, @CreateTS, @Empire, @X, @Y, @Z) SELECT Scope_Identity()"))
            {
                cmd.AddParameter("Username", DbType.String, securityUser.Username);
                cmd.AddParameter("EmailAddress", DbType.String, securityUser.EmailAddress);
                cmd.AddParameter("PasswordHash", DbType.Binary, securityUser.PasswordHash);
                cmd.AddParameter("PasswordSalt", DbType.String, securityUser.PasswordSalt);
                cmd.AddParameter("CreateTS", DbType.DateTime, securityUser.CreateTS);

                cmd.AddParameter("Empire", DbType.Int32, empireID);
                cmd.AddParameter("X", DbType.Int64, coordinates.X);
                cmd.AddParameter("Y", DbType.Int64, coordinates.Y);
                cmd.AddParameter("Z", DbType.Int64, coordinates.Z);

                securityUser.UserAccountID = (int)(decimal)cmd.ExecuteScalar();
            }
        }