From 9fe0cfb2d8b801e2ca637a0df1a28aeaa40abb59 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 24 Jan 2018 13:27:32 -0500 Subject: [PATCH] fix encryptCipherData --- src/models/view/cipherView.ts | 6 +++++- src/services/cipher.service.ts | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/models/view/cipherView.ts b/src/models/view/cipherView.ts index d111226913..50218527f8 100644 --- a/src/models/view/cipherView.ts +++ b/src/models/view/cipherView.ts @@ -30,7 +30,11 @@ export class CipherView implements View { // tslint:disable-next-line private _subTitle: string; - constructor(c: Cipher) { + constructor(c?: Cipher) { + if (!c) { + return; + } + this.id = c.id; this.organizationId = c.organizationId; this.folderId = c.folderId; diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index bec5c30dd6..784c3d8841 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -2,10 +2,14 @@ import { CipherType } from '../enums/cipherType'; import { CipherData } from '../models/data/cipherData'; +import { Card } from '../models/domain/card'; import { Cipher } from '../models/domain/cipher'; import { CipherString } from '../models/domain/cipherString'; import Domain from '../models/domain/domain'; import { Field } from '../models/domain/field'; +import { Identity } from '../models/domain/identity'; +import { Login } from '../models/domain/login'; +import { SecureNote } from '../models/domain/secureNote'; import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey'; import { CipherRequest } from '../models/request/cipherRequest'; @@ -472,7 +476,7 @@ export class CipherService implements CipherServiceAbstraction { private async encryptCipherData(cipher: Cipher, model: CipherView, key: SymmetricCryptoKey) { switch (cipher.type) { case CipherType.Login: - model.login = new LoginView(); + cipher.login = new Login(); await this.encryptObjProperty(model.login, cipher.login, { uri: null, username: null, @@ -481,12 +485,11 @@ export class CipherService implements CipherServiceAbstraction { }, key); return; case CipherType.SecureNote: - model.secureNote = { - type: cipher.secureNote.type, - }; + cipher.secureNote = new SecureNote(); + cipher.secureNote.type = model.secureNote.type; return; case CipherType.Card: - model.card = new CardView(); + cipher.card = new Card(); await this.encryptObjProperty(model.card, cipher.card, { cardholderName: null, brand: null, @@ -497,7 +500,7 @@ export class CipherService implements CipherServiceAbstraction { }, key); return; case CipherType.Identity: - model.identity = new IdentityView(); + cipher.identity = new Identity(); await this.encryptObjProperty(model.identity, cipher.identity, { title: null, firstName: null,