Merge pull request #104 from Hinton/feature/hide-passwords

Add support for collections with hide passwords
This commit is contained in:
Chad Scharf 2020-06-11 14:26:57 -04:00 committed by GitHub
commit 2b6657a293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 2 deletions

View File

@ -296,6 +296,7 @@ export class AddEditComponent implements OnInit {
const f = new FieldView(); const f = new FieldView();
f.type = this.addFieldType; f.type = this.addFieldType;
f.newField = true;
this.cipher.fields.push(f); this.cipher.fields.push(f);
} }

View File

@ -16,6 +16,7 @@ export class CipherData {
folderId: string; folderId: string;
userId: string; userId: string;
edit: boolean; edit: boolean;
viewPassword: boolean;
organizationUseTotp: boolean; organizationUseTotp: boolean;
favorite: boolean; favorite: boolean;
revisionDate: string; revisionDate: string;
@ -43,6 +44,7 @@ export class CipherData {
this.folderId = response.folderId; this.folderId = response.folderId;
this.userId = userId; this.userId = userId;
this.edit = response.edit; this.edit = response.edit;
this.viewPassword = response.viewPassword;
this.organizationUseTotp = response.organizationUseTotp; this.organizationUseTotp = response.organizationUseTotp;
this.favorite = response.favorite; this.favorite = response.favorite;
this.revisionDate = response.revisionDate; this.revisionDate = response.revisionDate;

View File

@ -24,6 +24,7 @@ export class Cipher extends Domain {
favorite: boolean; favorite: boolean;
organizationUseTotp: boolean; organizationUseTotp: boolean;
edit: boolean; edit: boolean;
viewPassword: boolean;
revisionDate: Date; revisionDate: Date;
localData: any; localData: any;
login: Login; login: Login;
@ -55,6 +56,7 @@ export class Cipher extends Domain {
this.favorite = obj.favorite; this.favorite = obj.favorite;
this.organizationUseTotp = obj.organizationUseTotp; this.organizationUseTotp = obj.organizationUseTotp;
this.edit = obj.edit; this.edit = obj.edit;
this.viewPassword = obj.viewPassword;
this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null; this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null;
this.collectionIds = obj.collectionIds; this.collectionIds = obj.collectionIds;
this.localData = localData; this.localData = localData;
@ -169,6 +171,7 @@ export class Cipher extends Domain {
c.folderId = this.folderId; c.folderId = this.folderId;
c.userId = this.organizationId != null ? userId : null; c.userId = this.organizationId != null ? userId : null;
c.edit = this.edit; c.edit = this.edit;
c.viewPassword = this.viewPassword;
c.organizationUseTotp = this.organizationUseTotp; c.organizationUseTotp = this.organizationUseTotp;
c.favorite = this.favorite; c.favorite = this.favorite;
c.revisionDate = this.revisionDate != null ? this.revisionDate.toISOString() : null; c.revisionDate = this.revisionDate != null ? this.revisionDate.toISOString() : null;

View File

@ -11,6 +11,7 @@ export class Collection extends Domain {
name: CipherString; name: CipherString;
externalId: string; externalId: string;
readOnly: boolean; readOnly: boolean;
hidePasswords: boolean;
constructor(obj?: CollectionData, alreadyEncrypted: boolean = false) { constructor(obj?: CollectionData, alreadyEncrypted: boolean = false) {
super(); super();
@ -24,7 +25,8 @@ export class Collection extends Domain {
name: null, name: null,
externalId: null, externalId: null,
readOnly: null, readOnly: null,
}, alreadyEncrypted, ['id', 'organizationId', 'externalId', 'readOnly']); hidePasswords: null,
}, alreadyEncrypted, ['id', 'organizationId', 'externalId', 'readOnly', 'hidePasswords']);
} }
decrypt(): Promise<CollectionView> { decrypt(): Promise<CollectionView> {

View File

@ -1,9 +1,11 @@
export class SelectionReadOnlyRequest { export class SelectionReadOnlyRequest {
id: string; id: string;
readOnly: boolean; readOnly: boolean;
hidePasswords: boolean;
constructor(id: string, readOnly: boolean) { constructor(id: string, readOnly: boolean, hidePasswords: boolean) {
this.id = id; this.id = id;
this.readOnly = readOnly; this.readOnly = readOnly;
this.hidePasswords = hidePasswords;
} }
} }

View File

@ -22,6 +22,7 @@ export class CipherResponse extends BaseResponse {
secureNote: SecureNoteApi; secureNote: SecureNoteApi;
favorite: boolean; favorite: boolean;
edit: boolean; edit: boolean;
viewPassword: boolean;
organizationUseTotp: boolean; organizationUseTotp: boolean;
revisionDate: string; revisionDate: string;
attachments: AttachmentResponse[]; attachments: AttachmentResponse[];
@ -39,6 +40,11 @@ export class CipherResponse extends BaseResponse {
this.notes = this.getResponseProperty('Notes'); this.notes = this.getResponseProperty('Notes');
this.favorite = this.getResponseProperty('Favorite') || false; this.favorite = this.getResponseProperty('Favorite') || false;
this.edit = !!this.getResponseProperty('Edit'); this.edit = !!this.getResponseProperty('Edit');
if (this.getResponseProperty('ViewPassword') == null) {
this.viewPassword = true;
} else {
this.viewPassword = this.getResponseProperty('ViewPassword');
}
this.organizationUseTotp = this.getResponseProperty('OrganizationUseTotp'); this.organizationUseTotp = this.getResponseProperty('OrganizationUseTotp');
this.revisionDate = this.getResponseProperty('RevisionDate'); this.revisionDate = this.getResponseProperty('RevisionDate');
this.collectionIds = this.getResponseProperty('CollectionIds'); this.collectionIds = this.getResponseProperty('CollectionIds');

View File

@ -3,10 +3,12 @@ import { BaseResponse } from './baseResponse';
export class SelectionReadOnlyResponse extends BaseResponse { export class SelectionReadOnlyResponse extends BaseResponse {
id: string; id: string;
readOnly: boolean; readOnly: boolean;
hidePasswords: boolean;
constructor(response: any) { constructor(response: any) {
super(response); super(response);
this.id = this.getResponseProperty('Id'); this.id = this.getResponseProperty('Id');
this.readOnly = this.getResponseProperty('ReadOnly'); this.readOnly = this.getResponseProperty('ReadOnly');
this.hidePasswords = this.getResponseProperty('HidePasswords');
} }
} }

View File

@ -21,6 +21,7 @@ export class CipherView implements View {
favorite = false; favorite = false;
organizationUseTotp = false; organizationUseTotp = false;
edit = false; edit = false;
viewPassword = true;
localData: any; localData: any;
login = new LoginView(); login = new LoginView();
identity = new IdentityView(); identity = new IdentityView();
@ -44,6 +45,7 @@ export class CipherView implements View {
this.favorite = c.favorite; this.favorite = c.favorite;
this.organizationUseTotp = c.organizationUseTotp; this.organizationUseTotp = c.organizationUseTotp;
this.edit = c.edit; this.edit = c.edit;
this.viewPassword = c.viewPassword;
this.type = c.type; this.type = c.type;
this.localData = c.localData; this.localData = c.localData;
this.collectionIds = c.collectionIds; this.collectionIds = c.collectionIds;

View File

@ -11,6 +11,7 @@ export class CollectionView implements View, ITreeNodeObject {
name: string = null; name: string = null;
externalId: string = null; externalId: string = null;
readOnly: boolean = null; readOnly: boolean = null;
hidePasswords: boolean = null;
constructor(c?: Collection | CollectionGroupDetailsResponse) { constructor(c?: Collection | CollectionGroupDetailsResponse) {
if (!c) { if (!c) {
@ -22,6 +23,7 @@ export class CollectionView implements View, ITreeNodeObject {
this.externalId = c.externalId; this.externalId = c.externalId;
if (c instanceof Collection) { if (c instanceof Collection) {
this.readOnly = c.readOnly; this.readOnly = c.readOnly;
this.hidePasswords = c.hidePasswords;
} }
} }
} }

View File

@ -8,6 +8,7 @@ export class FieldView implements View {
name: string = null; name: string = null;
value: string = null; value: string = null;
type: FieldType = null; type: FieldType = null;
newField: boolean = false; // Marks if the field is new and hasn't been saved
constructor(f?: Field) { constructor(f?: Field) {
if (!f) { if (!f) {