예제 #1
0
        private User FindByUserNameOrEmail(string userNameOrEmail)
        {
            var users = Entities
                        .Users
                        .Include(u => u.Credentials)
                        .Include(u => u.Roles);

            var user = users.SingleOrDefault(u => u.Username == userNameOrEmail);

            if (user == null)
            {
                var allMatches = users
                                 .Where(u => u.EmailAddress == userNameOrEmail)
                                 .Take(2)
                                 .ToList();

                if (allMatches.Count == 1)
                {
                    user = allMatches[0];
                }
                else
                {
                    // If multiple matches, leave it null to signal no unique email address
                    _trace.Warning($"Multiple user accounts with a single email address were found. Count: {allMatches.Count}");
                }
            }
            return(user);
        }
예제 #2
0
        private User FindByUserNameOrEmail(string userNameOrEmail)
        {
            var users = UserService.GetUsers();
            var user  = users.SingleOrDefault(u => u.Username == userNameOrEmail);

            if (user != null)
            {
                return(user);
            }

            var allMatches = users
                             .Where(u => u.EmailAddress == userNameOrEmail)
                             .Take(2)
                             .ToList();

            if (allMatches.Count == 1)
            {
                user = allMatches[0];
            }
            else
            {
                // If multiple matches, leave it null to signal no unique email address
                Trace.Warning("Multiple user accounts with email address: " + userNameOrEmail + " found: " + String.Join(", ", allMatches.Select(u => u.Username)));
            }
            return(user);
        }
예제 #3
0
        public void TraceException(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

            _diagnosticsSource.Warning(exception.ToString());
        }