mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-03 18:28:13 +01:00
Default values for cipher.reprompt (#367)
* Set default cipher.reprompt value for imports * Set default cipher.reprompt value for new ciphers * Add support for importing bitwarden exports * Add default cipher.reprompt for JSON imports Co-authored-by: Hinton <oscar@oscarhinton.com>
This commit is contained in:
parent
2841cff90a
commit
d184b0d2d6
@ -228,6 +228,7 @@ export class AddEditComponent implements OnInit {
|
||||
this.cipher.identity = new IdentityView();
|
||||
this.cipher.secureNote = new SecureNoteView();
|
||||
this.cipher.secureNote.type = SecureNoteType.Generic;
|
||||
this.cipher.reprompt = CipherRepromptType.None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import { FolderView } from '../models/view/folderView';
|
||||
import { LoginView } from '../models/view/loginView';
|
||||
import { SecureNoteView } from '../models/view/secureNoteView';
|
||||
|
||||
import { CipherRepromptType } from '../enums/cipherRepromptType';
|
||||
import { CipherType } from '../enums/cipherType';
|
||||
import { FieldType } from '../enums/fieldType';
|
||||
import { SecureNoteType } from '../enums/secureNoteType';
|
||||
|
@ -10,6 +10,7 @@ import { FolderView } from '../models/view/folderView';
|
||||
import { LoginView } from '../models/view/loginView';
|
||||
import { SecureNoteView } from '../models/view/secureNoteView';
|
||||
|
||||
import { CipherRepromptType } from '../enums/cipherRepromptType';
|
||||
import { CipherType } from '../enums/cipherType';
|
||||
import { FieldType } from '../enums/fieldType';
|
||||
import { SecureNoteType } from '../enums/secureNoteType';
|
||||
@ -55,6 +56,13 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
|
||||
cipher.type = CipherType.Login;
|
||||
cipher.notes = this.getValueOrDefault(value.notes);
|
||||
cipher.name = this.getValueOrDefault(value.name, '--');
|
||||
try {
|
||||
cipher.reprompt = parseInt(this.getValueOrDefault(value.reprompt, CipherRepromptType.None.toString()), 10);
|
||||
} catch (e) {
|
||||
// tslint:disable-next-line
|
||||
console.error('Unable to parse reprompt value', e);
|
||||
cipher.reprompt = CipherRepromptType.None;
|
||||
}
|
||||
|
||||
if (!this.isNullOrWhitespace(value.fields)) {
|
||||
const fields = this.splitNewLine(value.fields);
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { CipherRepromptType } from '../../enums/cipherRepromptType';
|
||||
import { CipherType } from '../../enums/cipherType';
|
||||
|
||||
import { CipherView } from '../view/cipherView';
|
||||
@ -26,6 +27,7 @@ export class Cipher {
|
||||
req.secureNote = null;
|
||||
req.card = null;
|
||||
req.identity = null;
|
||||
req.reprompt = CipherRepromptType.None;
|
||||
return req;
|
||||
}
|
||||
|
||||
@ -42,6 +44,7 @@ export class Cipher {
|
||||
view.name = req.name;
|
||||
view.notes = req.notes;
|
||||
view.favorite = req.favorite;
|
||||
view.reprompt = req.reprompt ?? CipherRepromptType.None;
|
||||
|
||||
if (req.fields != null) {
|
||||
view.fields = req.fields.map(f => Field.toView(f));
|
||||
@ -74,6 +77,7 @@ export class Cipher {
|
||||
domain.name = req.name != null ? new EncString(req.name) : null;
|
||||
domain.notes = req.notes != null ? new EncString(req.notes) : null;
|
||||
domain.favorite = req.favorite;
|
||||
domain.reprompt = req.reprompt ?? CipherRepromptType.None;
|
||||
|
||||
if (req.fields != null) {
|
||||
domain.fields = req.fields.map(f => Field.toDomain(f));
|
||||
@ -109,12 +113,14 @@ export class Cipher {
|
||||
secureNote: SecureNote;
|
||||
card: Card;
|
||||
identity: Identity;
|
||||
reprompt: CipherRepromptType;
|
||||
|
||||
// Use build method instead of ctor so that we can control order of JSON stringify for pretty print
|
||||
build(o: CipherView | CipherDomain) {
|
||||
this.organizationId = o.organizationId;
|
||||
this.folderId = o.folderId;
|
||||
this.type = o.type;
|
||||
this.reprompt = o.reprompt;
|
||||
|
||||
if (o instanceof CipherView) {
|
||||
this.name = o.name;
|
||||
|
@ -34,7 +34,7 @@ export class CipherView implements View {
|
||||
collectionIds: string[] = null;
|
||||
revisionDate: Date = null;
|
||||
deletedDate: Date = null;
|
||||
reprompt: CipherRepromptType = null;
|
||||
reprompt: CipherRepromptType = CipherRepromptType.None;
|
||||
|
||||
constructor(c?: Cipher) {
|
||||
if (!c) {
|
||||
|
@ -308,6 +308,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
cipher.name = c.name;
|
||||
cipher.notes = c.notes;
|
||||
cipher.fields = null;
|
||||
cipher.reprompt = c.reprompt;
|
||||
// Login props
|
||||
cipher.login_uri = null;
|
||||
cipher.login_username = null;
|
||||
|
Loading…
Reference in New Issue
Block a user