private void DeleteAuthentication(Guid entityId)
        {
            _logService.Info("Hard deleting User Credentials: {0}", entityId);

            _authenticationRepository.Delete(entityId);

            _logService.Info("Hard deleted User Credentials: {0}", entityId);
        }
 public Tuple <bool, string> DeleteAuthentication(long id)
 {
     try
     {
         if (_userRepository.Contains(x => x.AuthenticationId == id))
         {
             return(new Tuple <bool, string>(false, "رکورد مورد نظر استفاده شده است ، لذا قابل حذف نمی باشد"));
         }
         _authenticationRepository.Delete(x => x.Id == id);
         _unitOfWork.SaveChanges();
         return(new Tuple <bool, string>(true, "عملیات حذف به درستی انجام شد"));
     }
     catch (Exception ex)
     {
         return(new Tuple <bool, string>(false, "خطا در انجام عملیات"));
     }
 }
示例#3
0
        /// <inheritdoc/>
        public int DeleteAllDevices(Guid user)
        {
            var raw = _authenticationRepository.Get(new AuthenticationInfoQuery()
            {
                DeviceId = _appHost.SystemId,
                UserId   = user
            });

            var tokens = raw.Items.Where(x => x.AppName.StartsWith(TokenName, StringComparison.Ordinal));

            var removed = 0;

            foreach (var token in tokens)
            {
                _authenticationRepository.Delete(token);
                _logger.LogDebug("Deleted token {AccessToken}", token.AccessToken);
                removed++;
            }

            return(removed);
        }
        public void UpdateUsername(Guid userId, string verfiyCode, string password)
        {
            var user = _userReadRepository.Get(userId);

            if (!verfiyCode.Equals(user.PendingUsernameCode, StringComparison.InvariantCultureIgnoreCase))
            {
                _logService.Debug("UpdateUsername failed to validate PendingUsernameCode: {0} for userId: {1}", verfiyCode, userId);
                throw new CustomException(ErrorCodes.InvalidUpdateUsernameCode);
            }

            if (!_userDirectoryProvider.AuthenticateUser(userId.ToString(), password))
            {
                _logService.Debug("UpdateUsername failed to autheticate userId: {0}", userId);
                throw new CustomException(ErrorCodes.UserPasswordError);
            }

            var pendingActivationUser = _userReadRepository.Get(user.PendingUsername, false);

            if (pendingActivationUser != null && pendingActivationUser.Status != UserStatuses.PendingDeletion)
            {
                //Delete any user with username = user.PendingUsername - they must be PendingActivation
                if (pendingActivationUser.Status != UserStatuses.PendingActivation)
                {
                    _logService.Error("UpdateUsername error, existing userId ({0}) to pending username ({1}) failed as username already exists and is not in PendingActivation state", userId, user.PendingUsername);
                    throw new CustomException(ErrorCodes.UsernameExistsAndNotInPendingActivationState);
                }
                _userWriteRepository.Delete(pendingActivationUser.EntityId);
                _authenticationRepository.Delete(pendingActivationUser.EntityId);
            }

            _logService.Info("UpdateUsername updating from '{0}' to '{1}'", user.Username, user.PendingUsername);
            _auditRepository.Audit(user, AuditEventTypes.UsernameChanged, user.EntityId);
            user.Username            = user.PendingUsername;
            user.PendingUsername     = null;
            user.PendingUsernameCode = null;
            _userWriteRepository.Save(user);
            _logService.Info("UpdateUsername updated to '{0}'", user.Username);
        }
 public bool DeleteUser(string userName, string password)
 {
     return(m_authentication.Delete(userName, password));
 }
示例#6
0
 public void DeleteUsers()
 {
     authenticationRepo.Delete("Admin", "pass");
 }