Beispiel #1
0
 public void ExceptionsTest()
 {
     Assert.Throws <HivemindException>(() => HivemindException.GangerNotFoundException(-1));
     Assert.Throws <HivemindException>(() => HivemindException.NoSuchInjuryException(-1));
     Assert.Throws <HivemindException>(() => HivemindException.NoSuchGangHouse());
     Assert.Throws <HivemindException>(() => HivemindException.InvalidUsernameOrPassword());
 }
Beispiel #2
0
        private void AuthenticateUser(Entities.Login user, Entities.Login userFromDatabase)
        {
            if (user == null || user.Email == null || userFromDatabase == null)
            {
                HivemindException.InvalidUsernameOrPassword();
            }

            if (!BCrypt.Net.BCrypt.Verify(user.Password, userFromDatabase.Password))
            {
                HivemindException.InvalidUsernameOrPassword();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get a user by ID
        /// </summary>
        /// <param name="userGuid">User GUID</param>
        /// <returns>User</returns>
        public Contracts.User GetUser(string userGuid)
        {
            if (string.IsNullOrEmpty(userGuid))
            {
                HivemindException.InvalidUsernameOrPassword();
            }

            var user         = _userProvider.GetUserByGuid(userGuid);
            var userContract = user.ToContract();

            GetUserGangs(ref userContract);

            return(userContract);
        }