예제 #1
0
 public void Add(ChatUserIdentity identity)
 {
     _identities.Add(identity);
     if (identity.User != null)
     {
         identity.User.Identities.Add(identity);
     }
 }
예제 #2
0
        private ChatUser AddUser(string userName, string providerName, string identity, string email)
        {
            if (!IsValidUserName(userName))
            {
                throw new InvalidOperationException(String.Format(LanguageResources.UserInvalidName, userName));
            }

            EnsureProviderAndIdentityAvailable(providerName, identity);

            // This method is used in the auth workflow. If the username is taken it will add a number
            // to the user name.
            if (UserExists(userName))
            {
                var usersWithNameLikeMine = _repository.Users.Count(u => u.Name.StartsWith(userName));
                userName += usersWithNameLikeMine;
            }

            var user = new ChatUser
            {
                Name = userName,
                Status = (int)UserStatus.Active,
                Hash = email.ToMD5(),
                Id = Guid.NewGuid().ToString("d"),
                LastActivity = DateTime.UtcNow,
                IsAdmin = IsFirstUser()
            };

            var chatUserIdentity = new ChatUserIdentity
            {
                User = user,
                Email = email,
                Identity = identity,
                ProviderName = providerName
            };

            _repository.Add(user);
            _repository.Add(chatUserIdentity);
            _repository.CommitChanges();

            return user;
        }
예제 #3
0
 public void Remove(ChatUserIdentity identity)
 {
     _identities.Remove(identity);
 }
예제 #4
0
 public void Remove(ChatUserIdentity identity)
 {
     _db.Identities.Remove(identity);
     _db.SaveChanges();
 }
예제 #5
0
 public void Add(ChatUserIdentity identity)
 {
     _db.Identities.Add(identity);
     _db.SaveChanges();
 }