コード例 #1
0
        public async Task <RecipientResponse> AddOfficer([FromBody] AddOfficerRequest addOfficerRequest)
        {
            var folder = await connection.Folder.GetAsync(addOfficerRequest.FolderIdentifier);

            var recipients = folder.MetaLEOUploadOfficerListRead();
            var recipient  = recipients.Where(rec => rec?.Email?.ToLower() == addOfficerRequest.RecipientEmail.ToLower()).FirstOrDefault();

            if (recipient != null)
            {
                throw new RecipientAlreadyPresentException($"You can't add: {addOfficerRequest.RecipientEmail} this officer as they are already present in the list of officers.");
            }

            return(await leoUpload.AddRecipientAsync(
                       addOfficerRequest,
                       managerConfiguration.LEOUploadLandingLocation,
                       managerConfiguration.LEOUploadLinkEncryptionKey
                       ));
        }
コード例 #2
0
        public ActionResult <EventsResponse> AddOfficer(AddOfficerRequest model)
        {
            // only admins can create albums
            if (Account.Role != Role.Admin)
            {
                return(Unauthorized(new { message = "Unauthorized" }));
            }
            // map model to new account object
            var officer = _mapper.Map <Officer>(model);

            // validate
            if (_repository.Officer.OfficerWithRoleExists(model.Role))
            {
                throw new AppException($"This Officer Role is currently occupied.");
            }

            _repository.Officer.AddOfficer(ref officer, Account.Id, model.MemberId);
            _logger.LogInfo("Officer created and added to database");
            var officerResponse = _mapper.Map <OfficerResponse>(officer);

            return(Ok(officerResponse));
        }
コード例 #3
0
        public async Task <RecipientResponse> AddRecipientAsync(AddOfficerRequest addOfficerRequest, string landingLocation, string passphrase)
        {
            var folder = await connection.Folder.GetAsync(addOfficerRequest.FolderIdentifier);

            DateTime?expirationDate = ModuleUtility.GetLinkExpirationDate(folder, MetadataKeyConstants.LEO_UPLOAD_EXPIRATION_LENGTH_SECONDS);

            var password = ModuleUtility.GeneratePassword(
                folder,
                MetadataKeyConstants.LEO_UPLOAD_RND_PASSWORD_LENGTH,
                LEOUploadUtility.LEO_UPLOAD_DEFAULT_PASSWORD_LENGTH,
                MetadataKeyConstants.LEO_UPLOAD_RND_PASSWORD_CHARS);

            // We're going to generate a user for eDicsovery.  This user will have restricted priveleges.
            var user = await GenerateUser(addOfficerRequest, password.Plain);

            string completeUrl = ModuleUtility.CreateMagicLink(addOfficerRequest, landingLocation, passphrase, folder.Identifier, expirationDate, user.Identifier);

            await connection.ConcurrencyRetryBlock(async() =>
            {
                folder = await connection.Folder.GetAsync(addOfficerRequest.FolderIdentifier);

                folder.MetaLEOUploadOfficerListUpsert(new ExternalUser()
                {
                    Email          = addOfficerRequest.RecipientEmail,
                    FirstName      = addOfficerRequest.FirstName,
                    LastName       = addOfficerRequest.LastName,
                    PasswordHash   = password.Hashed,
                    MagicLink      = completeUrl,
                    ExpirationDate = expirationDate.GetValueOrDefault()
                });

                var childPath = GetOfficerPath(addOfficerRequest.FolderIdentifier, addOfficerRequest.FirstName, addOfficerRequest.LastName);

                var allPaths = folder.Read("_paths", defaultValue: new List <string>());

                allPaths.Add(childPath.FullName);

                folder.Write("_paths", allPaths);

                await connection.Folder.PutAsync(folder);
            });

            await this.auditLogStore.AddEntry(
                new AuditLogEntry()
            {
                EntryType  = AuditLogEntryType.LEOUploadOfficerAdded,
                Message    = $"A LEO officer has been added. {addOfficerRequest.RecipientEmail}",
                ModuleType = Modules.ModuleType.LEOUpload
            },
                folder.Identifier
                );

            // build up the response
            return(new RecipientResponse()
            {
                Email = addOfficerRequest.RecipientEmail,
                ExpirationDate = expirationDate.GetValueOrDefault(),
                MagicLink = completeUrl,
                Password = password.Plain,
                FirstName = addOfficerRequest.FirstName,
                LastName = addOfficerRequest.LastName,
            });
        }