public UserCreateStatus CreateAccount(string remoteUsername, string fullname, string email) { bool exists = Repository.FirstOrDefault(u => u.RemoteCredentials != null && u.RemoteCredentials.Username == remoteUsername) != null; if (!exists) { UserAccount user = new UserAccount { PublicIdentifier = HashHelper.ComputePublicIdentifier(typeof(UserAccount).Name, remoteUsername), RemoteCredentials = new RemoteCredentials { Username = remoteUsername }, Enabled = true, Created = DateTime.Now, Fullname = fullname, Email = email, UserRole = UserRole.User }; Repository.Insert(user); return(UserCreateStatus.Created); } ActivityService.UserRegistered(remoteUsername); return(UserCreateStatus.UsernameUsed); }
public UserCreateStatus CreateAccount(string username, string password, string fullname, string email) { bool exists = Repository.FirstOrDefault(u => u.LocalCredentials != null && u.LocalCredentials.Username == username) != null; if (!exists) { if (!Validator.CheckPassword(password)) { return(UserCreateStatus.InsufficientPassword); } UserAccount user = new UserAccount { PublicIdentifier = HashHelper.ComputePublicIdentifier(typeof(UserAccount).Name, username), LocalCredentials = new LocalCredentials { Username = username, Password = HashHelper.ComputePassword(username, password) }, Enabled = true, Created = DateTime.Now, Fullname = fullname, Email = email, UserRole = UserRole.User }; Repository.Insert(user); return(UserCreateStatus.Created); } ActivityService.UserRegistered(username); return(UserCreateStatus.UsernameUsed); }