Add support for collections with hide passwords

This commit is contained in:
hinton 2020-05-21 15:49:56 +02:00
parent 2858724f44
commit 1fa3eb49ad
8 changed files with 24 additions and 3 deletions

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[];
@ -38,7 +39,12 @@ export class CipherResponse extends BaseResponse {
this.name = this.getResponseProperty('Name'); this.name = this.getResponseProperty('Name');
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') || true; 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;
} }
} }
} }