Пример #1
0
        private async Task <UserProfile> DangerouslyCreateUserProfile(DTO.UserProfile.Create userData)
        {
            var userAccount = new EF.Models.UserProfile(userData.Id, userData.DisplayName, userData.Email);
            await context.UserProfiles.AddAsync(userAccount);

            var pendingInvites = await context.TeamInvites.Where(i => string.Equals(i.Email, userData.Email, System.StringComparison.CurrentCultureIgnoreCase)).ToListAsync();

            if (pendingInvites.Any())
            {
                foreach (var invite in pendingInvites)
                {
                    invite.UserProfileId = userData.Id;
                    var invitePermission = new Permission(userData.Id, AuthorizationHelper.GenerateARN(typeof(EF.Models.TeamInvite), invite.Id.ToString(), Shared.Permissions.TeamInvite.All));
                    context.Permissions.Add(invitePermission);
                }

                context.TeamInvites.UpdateRange(pendingInvites);
            }
            return(userAccount);
        }
Пример #2
0
        public async Task <ServiceResult> CreateAccount(DTO.UserProfile.Create account)
        {
            var result = new ServiceResult();

            if (context.UserProfiles.Any(u => u.Email == account.Email || u.DisplayName == account.DisplayName || u.Id == account.Id))
            {
                result.Error = Shared.ErrorKey.UserProfile.ProfileExists;
                return(result);
            }

            await DangerouslyCreateUserProfile(account);

            result.Succeed();
            await this.backgroundWorker.SendMessage(this.queues.Contact, new DTO.Marketing.ContactSync(account.Id, true), 5);


            var profanityCheck = await this.profanityValidator.Check(account.DisplayName);

            if (profanityCheck.Severity == ProfanityFilterSeverity.Blacklist || profanityCheck.Severity == ProfanityFilterSeverity.Suspicious)
            {
                this.slackClient.SendMessage($"[SEVERITY {(int)profanityCheck.Severity}] User {account.DisplayName} ({account.Id}) has been created", Shared.ExternalResources.Slack.ProfanityFilterChannel);
            }
            return(result);
        }