mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Hide email address in Sends (#310)
* Let organizations disable anonymous Sends only * Add HideEmail to send models and service * Delete unnecessary model * Enforce new Send policy, fix naming conventions * Fix linting * Fully disable editing anonymous Sends per policy * Revert disableSendPolicy, add sendOptionsPolicy * Rework UI for enforcing disableHideEmail * Fix linting and cleanup after refactor
This commit is contained in:
parent
cfc7687815
commit
0735569479
@ -47,6 +47,7 @@ export class AddEditComponent implements OnInit {
|
||||
|
||||
copyLink = false;
|
||||
disableSend = false;
|
||||
disableHideEmail = false;
|
||||
send: SendView;
|
||||
deletionDate: string;
|
||||
deletionDateFallback: string;
|
||||
@ -149,14 +150,23 @@ export class AddEditComponent implements OnInit {
|
||||
}
|
||||
|
||||
async load() {
|
||||
const policies = await this.policyService.getAll(PolicyType.DisableSend);
|
||||
const disableSendPolicies = await this.policyService.getAll(PolicyType.DisableSend);
|
||||
const organizations = await this.userService.getAllOrganizations();
|
||||
this.disableSend = organizations.some(o => {
|
||||
return o.enabled &&
|
||||
o.status === OrganizationUserStatusType.Confirmed &&
|
||||
o.usePolicies &&
|
||||
!o.canManagePolicies &&
|
||||
policies.some(p => p.organizationId === o.id && p.enabled);
|
||||
disableSendPolicies.some(p => p.organizationId === o.id && p.enabled);
|
||||
});
|
||||
|
||||
const sendOptionsPolicies = await this.policyService.getAll(PolicyType.SendOptions);
|
||||
this.disableHideEmail = await organizations.some(o => {
|
||||
return o.enabled &&
|
||||
o.status === OrganizationUserStatusType.Confirmed &&
|
||||
o.usePolicies &&
|
||||
!o.canManagePolicies &&
|
||||
sendOptionsPolicies.some(p => p.organizationId === o.id && p.enabled && p.data.disableHideEmail);
|
||||
});
|
||||
|
||||
this.canAccessPremium = await this.userService.canAccessPremium();
|
||||
|
@ -6,4 +6,5 @@ export enum PolicyType {
|
||||
RequireSso = 4, // Requires users to authenticate with SSO
|
||||
PersonalOwnership = 5, // Disables personal vault ownership for adding/cloning items
|
||||
DisableSend = 6, // Disables the ability to create and edit Bitwarden Sends
|
||||
SendOptions = 7, // Sets restrictions or defaults for Bitwarden Sends
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ export class SendData {
|
||||
deletionDate: string;
|
||||
password: string;
|
||||
disabled: boolean;
|
||||
hideEmail: boolean;
|
||||
|
||||
constructor(response?: SendResponse, userId?: string) {
|
||||
if (response == null) {
|
||||
@ -42,6 +43,7 @@ export class SendData {
|
||||
this.deletionDate = response.deletionDate;
|
||||
this.password = response.password;
|
||||
this.disabled = response.disable;
|
||||
this.hideEmail = response.hideEmail;
|
||||
|
||||
switch (this.type) {
|
||||
case SendType.Text:
|
||||
|
@ -30,6 +30,7 @@ export class Send extends Domain {
|
||||
deletionDate: Date;
|
||||
password: string;
|
||||
disabled: boolean;
|
||||
hideEmail: boolean;
|
||||
|
||||
constructor(obj?: SendData, alreadyEncrypted: boolean = false) {
|
||||
super();
|
||||
@ -54,6 +55,7 @@ export class Send extends Domain {
|
||||
this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null;
|
||||
this.deletionDate = obj.deletionDate != null ? new Date(obj.deletionDate) : null;
|
||||
this.expirationDate = obj.expirationDate != null ? new Date(obj.expirationDate) : null;
|
||||
this.hideEmail = obj.hideEmail;
|
||||
|
||||
switch (this.type) {
|
||||
case SendType.Text:
|
||||
|
@ -18,6 +18,7 @@ export class SendRequest {
|
||||
file: SendFileApi;
|
||||
password: string;
|
||||
disabled: boolean;
|
||||
hideEmail: boolean;
|
||||
|
||||
constructor(send: Send, fileLength?: number) {
|
||||
this.type = send.type;
|
||||
@ -30,6 +31,7 @@ export class SendRequest {
|
||||
this.key = send.key != null ? send.key.encryptedString : null;
|
||||
this.password = send.password;
|
||||
this.disabled = send.disabled;
|
||||
this.hideEmail = send.hideEmail;
|
||||
|
||||
switch (this.type) {
|
||||
case SendType.Text:
|
||||
|
@ -21,6 +21,7 @@ export class SendResponse extends BaseResponse {
|
||||
deletionDate: string;
|
||||
password: string;
|
||||
disable: boolean;
|
||||
hideEmail: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
@ -37,6 +38,7 @@ export class SendResponse extends BaseResponse {
|
||||
this.deletionDate = this.getResponseProperty('DeletionDate');
|
||||
this.password = this.getResponseProperty('Password');
|
||||
this.disable = this.getResponseProperty('Disabled') || false;
|
||||
this.hideEmail = this.getResponseProperty('HideEmail') || false;
|
||||
|
||||
const text = this.getResponseProperty('Text');
|
||||
if (text != null) {
|
||||
|
@ -25,6 +25,7 @@ export class SendView implements View {
|
||||
expirationDate: Date = null;
|
||||
password: string = null;
|
||||
disabled: boolean = false;
|
||||
hideEmail: boolean = false;
|
||||
|
||||
constructor(s?: Send) {
|
||||
if (!s) {
|
||||
@ -41,6 +42,7 @@ export class SendView implements View {
|
||||
this.expirationDate = s.expirationDate;
|
||||
this.disabled = s.disabled;
|
||||
this.password = s.password;
|
||||
this.hideEmail = s.hideEmail;
|
||||
}
|
||||
|
||||
get urlB64Key(): string {
|
||||
|
@ -50,6 +50,7 @@ export class SendService implements SendServiceAbstraction {
|
||||
send.id = model.id;
|
||||
send.type = model.type;
|
||||
send.disabled = model.disabled;
|
||||
send.hideEmail = model.hideEmail;
|
||||
send.maxAccessCount = model.maxAccessCount;
|
||||
if (model.key == null) {
|
||||
model.key = await this.cryptoFunctionService.randomBytes(16);
|
||||
|
Loading…
Reference in New Issue
Block a user