1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

updates to status command and add hidePasswords (#146)

* a few updates to the recent status addition

* add hidePasswords functionality
This commit is contained in:
Kyle Spearrin 2020-06-17 11:01:34 -04:00 committed by GitHub
parent 62c7c30cb4
commit 72c56ca506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 23 deletions

2
jslib

@ -1 +1 @@
Subproject commit 212a2e3745e6e0e2b3057ed308c47daf6aeefbc8
Subproject commit 28d21ca5dfacd1487cd92345d8be9554079fbd96

View File

@ -149,7 +149,7 @@ export class CreateCommand {
}
const groups = req.groups == null ? null :
req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly));
req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords));
const request = new CollectionRequest();
request.name = (await this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
request.externalId = req.externalId;

View File

@ -147,7 +147,7 @@ export class EditCommand {
}
const groups = req.groups == null ? null :
req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly));
req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords));
const request = new CollectionRequest();
request.name = (await this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
request.externalId = req.externalId;

View File

@ -367,7 +367,7 @@ export class GetCommand {
decCollection.name = await this.cryptoService.decryptToUtf8(
new CipherString(response.name), orgKey);
const groups = response.groups == null ? null :
response.groups.map((g) => new SelectionReadOnly(g.id, g.readOnly));
response.groups.map((g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords));
const res = new OrganizationCollectionResponse(decCollection, groups);
return Response.success(res);
} catch (e) {

View File

@ -1,15 +1,17 @@
import * as program from 'commander';
import { EnvironmentService, SyncService, UserService, VaultTimeoutService } from 'jslib/abstractions';
import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { SyncService } from 'jslib/abstractions/sync.service';
import { UserService } from 'jslib/abstractions/user.service';
import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
import { Response } from 'jslib/cli/models/response';
import { TemplateResponse } from '../models/response/templateResponse';
export class StatusCommand {
constructor(
private envService: EnvironmentService,
private syncService: SyncService,
private userService: UserService,
private vaultTimeoutService: VaultTimeoutService) {
constructor(private envService: EnvironmentService, private syncService: SyncService,
private userService: UserService, private vaultTimeoutService: VaultTimeoutService) {
}
async run(cmd: program.Command): Promise<Response> {
@ -41,16 +43,12 @@ export class StatusCommand {
}
private async status(): Promise<string> {
const isAuthed = await this.userService.isAuthenticated();
if (!isAuthed) {
const authed = await this.userService.isAuthenticated();
if (!authed) {
return 'unauthenticated';
}
const isLocked = await this.vaultTimeoutService.isLocked();
if (isLocked) {
return 'locked';
} else {
return 'unlocked';
}
return isLocked ? 'locked' : 'unlocked';
}
}

View File

@ -1,13 +1,15 @@
export class SelectionReadOnly {
static template(): SelectionReadOnly {
return new SelectionReadOnly('00000000-0000-0000-0000-000000000000', false);
return new SelectionReadOnly('00000000-0000-0000-0000-000000000000', false, false);
}
id: string;
readOnly: boolean;
hidePasswords: boolean;
constructor(id: string, readOnly: boolean) {
constructor(id: string, readOnly: boolean, hidePasswords: boolean) {
this.id = id;
this.readOnly = readOnly;
this.hidePasswords = hidePasswords || false;
}
}

View File

@ -699,10 +699,12 @@ export class Program extends BaseProgram {
writeLn(' "status": "locked"');
writeLn(' }');
writeLn('');
writeLn(' The "status" is one of "unauthenticated", "locked", "unlocked":');
writeLn(' - "unauthenticated" when you are not logged in');
writeLn(' - "locked" when you are logged in and the vault is locked');
writeLn(' - "unlocked" when you are logged in and the vault is unlocked');
writeLn(' Notes:');
writeLn('');
writeLn(' `status` is one of:');
writeLn(' - `unauthenticated` when you are not logged in');
writeLn(' - `locked` when you are logged in and the vault is locked');
writeLn(' - `unlocked` when you are logged in and the vault is unlocked');
writeLn('', true);
})
.action(async (cmd: program.Command) => {