@ -11,6 +11,7 @@ import { ToasterService } from 'angular2-toaster';
@@ -11,6 +11,7 @@ import { ToasterService } from 'angular2-toaster';
import { CipherService } from 'jslib/abstractions/cipher.service' ;
import { EventService } from 'jslib/abstractions/event.service' ;
import { I18nService } from 'jslib/abstractions/i18n.service' ;
import { PasswordRepromptService } from 'jslib/abstractions/passwordReprompt.service' ;
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service' ;
import { SearchService } from 'jslib/abstractions/search.service' ;
import { TotpService } from 'jslib/abstractions/totp.service' ;
@ -18,6 +19,7 @@ import { UserService } from 'jslib/abstractions/user.service';
@@ -18,6 +19,7 @@ import { UserService } from 'jslib/abstractions/user.service';
import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component' ;
import { CipherRepromptType } from 'jslib/enums/cipherRepromptType' ;
import { CipherType } from 'jslib/enums/cipherType' ;
import { EventType } from 'jslib/enums/eventType' ;
@ -43,7 +45,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@@ -43,7 +45,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
constructor ( searchService : SearchService , protected toasterService : ToasterService ,
protected i18nService : I18nService , protected platformUtilsService : PlatformUtilsService ,
protected cipherService : CipherService , protected eventService : EventService ,
protected totpService : TotpService , protected userService : UserService ) {
protected totpService : TotpService , protected userService : UserService ,
protected passwordRepromptService : PasswordRepromptService ) {
super ( searchService ) ;
this . pageSize = 200 ;
}
@ -60,11 +63,17 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@@ -60,11 +63,17 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
this . platformUtilsService . launchUri ( uri ) ;
}
attachments ( c : CipherView ) {
async attachments ( c : CipherView ) {
if ( ! await this . repromptCipher ( c ) ) {
return ;
}
this . onAttachmentsClicked . emit ( c ) ;
}
share ( c : CipherView ) {
async share ( c : CipherView ) {
if ( ! await this . repromptCipher ( c ) ) {
return ;
}
this . onShareClicked . emit ( c ) ;
}
@ -72,11 +81,17 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@@ -72,11 +81,17 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
this . onCollectionsClicked . emit ( c ) ;
}
clone ( c : CipherView ) {
async clone ( c : CipherView ) {
if ( ! await this . repromptCipher ( c ) ) {
return ;
}
this . onCloneClicked . emit ( c ) ;
}
async delete ( c : CipherView ) : Promise < boolean > {
if ( ! await this . repromptCipher ( c ) ) {
return ;
}
if ( this . actionPromise != null ) {
return ;
}
@ -121,12 +136,20 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@@ -121,12 +136,20 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
}
async copy ( cipher : CipherView , value : string , typeI18nKey : string , aType : string ) {
if ( this . passwordRepromptService . protectedFields ( ) . includes ( aType ) && ! await this . repromptCipher ( cipher ) ) {
return ;
}
if ( value == null || aType === 'TOTP' && ! this . displayTotpCopyButton ( cipher ) ) {
return ;
} else if ( value === cipher . login . totp ) {
value = await this . totpService . getCode ( value ) ;
}
if ( ! cipher . viewPassword ) {
return ;
}
this . platformUtilsService . copyToClipboard ( value , { window : window } ) ;
this . toasterService . popAsync ( 'info' , null ,
this . i18nService . t ( 'valueCopied' , this . i18nService . t ( typeI18nKey ) ) ) ;
@ -170,6 +193,12 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@@ -170,6 +193,12 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
( cipher . organizationUseTotp || this . userHasPremiumAccess ) ;
}
async selectCipher ( cipher : CipherView ) {
if ( await this . repromptCipher ( cipher ) ) {
super . selectCipher ( cipher ) ;
}
}
protected deleteCipher ( id : string , permanent : boolean ) {
return permanent ? this . cipherService . deleteWithServer ( id ) : this . cipherService . softDeleteWithServer ( id ) ;
}
@ -177,4 +206,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@@ -177,4 +206,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
protected showFixOldAttachments ( c : CipherView ) {
return c . hasOldAttachments && c . organizationId == null ;
}
protected async repromptCipher ( c : CipherView ) {
return c . reprompt === CipherRepromptType . None || await this . passwordRepromptService . showPasswordPrompt ( ) ;
}
}