1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-08 06:28:14 -05:00

import ciphers, not logins

This commit is contained in:
Kyle Spearrin 2017-09-28 13:11:56 -04:00
parent 3762cebed4
commit 0abcdd9724
4 changed files with 14 additions and 4 deletions

View File

@ -212,7 +212,7 @@ namespace Bit.Api.Controllers
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var folders = model.Folders.Select(f => f.ToFolder(userId)).ToList(); var folders = model.Folders.Select(f => f.ToFolder(userId)).ToList();
var ciphers = model.Logins.Select(l => l.ToCipherDetails(userId)).ToList(); var ciphers = model.Ciphers.Select(c => c.ToCipherDetails(userId)).ToList();
await _cipherService.ImportCiphersAsync(folders, ciphers, model.FolderRelationships); await _cipherService.ImportCiphersAsync(folders, ciphers, model.FolderRelationships);
} }
@ -227,7 +227,7 @@ namespace Bit.Api.Controllers
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var collections = model.Collections.Select(c => c.ToCollection(orgId)).ToList(); var collections = model.Collections.Select(c => c.ToCollection(orgId)).ToList();
var ciphers = model.Logins.Select(l => l.ToOrganizationCipherDetails(orgId)).ToList(); var ciphers = model.Ciphers.Select(l => l.ToOrganizationCipherDetails(orgId)).ToList();
await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId); await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId);
} }

View File

@ -5,7 +5,7 @@ namespace Bit.Core.Models.Api
public class ImportCiphersRequestModel public class ImportCiphersRequestModel
{ {
public FolderRequestModel[] Folders { get; set; } public FolderRequestModel[] Folders { get; set; }
public LoginRequestModel[] Logins { get; set; } public CipherRequestModel[] Ciphers { get; set; }
public KeyValuePair<int, int>[] FolderRelationships { get; set; } public KeyValuePair<int, int>[] FolderRelationships { get; set; }
} }
} }

View File

@ -124,6 +124,16 @@ namespace Bit.Core.Models.Api
}); });
} }
public CipherDetails ToOrganizationCipherDetails(Guid orgId)
{
return ToCipherDetails(new CipherDetails
{
Type = Type,
OrganizationId = orgId,
Edit = true
});
}
public class LoginType public class LoginType
{ {
[EncryptedString] [EncryptedString]

View File

@ -5,7 +5,7 @@ namespace Bit.Core.Models.Api
public class ImportOrganizationCiphersRequestModel public class ImportOrganizationCiphersRequestModel
{ {
public CollectionRequestModel[] Collections { get; set; } public CollectionRequestModel[] Collections { get; set; }
public LoginRequestModel[] Logins { get; set; } public CipherRequestModel[] Ciphers { get; set; }
public KeyValuePair<int, int>[] CollectionRelationships { get; set; } public KeyValuePair<int, int>[] CollectionRelationships { get; set; }
} }
} }