1
0
mirror of https://github.com/bitwarden/web synced 2025-12-15 15:53:18 +00:00

Compare commits

..

9 Commits

Author SHA1 Message Date
Hinton
283f295481 Change fields to field(s) 2022-05-30 13:47:02 +02:00
Hinton
749ead5863 Move error summary below form 2022-05-23 17:15:21 +02:00
Hinton
8d369bcf84 Add error summary 2022-05-23 15:27:49 +02:00
Hinton
aa7fb1befb Add input i18n 2022-05-20 16:57:55 +02:00
Hinton
43ca31e0ae Validate before submit 2022-05-17 22:19:27 +02:00
Hinton
0dfc8c5a0b Merge branch 'master' of github.com:bitwarden/web into feature/cl-forms
# Conflicts:
#	jslib
2022-05-17 21:59:13 +02:00
Hinton
c1801dfc61 Merge branch 'master' of github.com:bitwarden/web into feature/cl-forms
# Conflicts:
#	jslib
2022-05-10 16:40:13 +02:00
Hinton
59a53740a4 Merge branch 'master' of github.com:bitwarden/web into feature/cl-forms
# Conflicts:
#	jslib
#	src/app/organizations/settings/account.component.html
#	src/app/organizations/settings/account.component.ts
#	src/app/oss.module.ts
2022-05-10 14:51:10 +02:00
Hinton
dd2c2b9720 Update Accounts form to use reactive forms and bit-form-field 2022-05-03 11:21:42 +02:00
26 changed files with 151 additions and 216 deletions

2
jslib

Submodule jslib updated: 52cc640537...3bf25edd3e

View File

@@ -101,7 +101,7 @@
<div [ngClass]="{ 'col-5': layout, 'col-12': !layout }"> <div [ngClass]="{ 'col-5': layout, 'col-12': !layout }">
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div [ngClass]="{ 'col-5': !layout, 'col-12': layout }"> <div [ngClass]="{ 'col-5': !layout, 'col-12': layout }">
<h1 class="lead text-center mb-4" *ngIf="!layout">{{ "createAccount" | i18n }}</h1> <p class="lead text-center mb-4" *ngIf="!layout">{{ "createAccount" | i18n }}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<app-callout <app-callout

View File

@@ -122,20 +122,17 @@ export abstract class BaseEventsComponent {
const userId = r.actingUserId == null ? r.userId : r.actingUserId; const userId = r.actingUserId == null ? r.userId : r.actingUserId;
const eventInfo = await this.eventService.getEventInfo(r); const eventInfo = await this.eventService.getEventInfo(r);
const user = this.getUserName(r, userId); const user = this.getUserName(r, userId);
const userName = user != null ? user.name : this.i18nService.t("unknown");
return new EventView({ return new EventView({
message: eventInfo.message, message: eventInfo.message,
humanReadableMessage: eventInfo.humanReadableMessage, humanReadableMessage: eventInfo.humanReadableMessage,
appIcon: eventInfo.appIcon, appIcon: eventInfo.appIcon,
appName: eventInfo.appName, appName: eventInfo.appName,
userId: userId, userId: userId,
userName: r.installationId != null ? `Installation: ${r.installationId}` : userName, userName: user != null ? user.name : this.i18nService.t("unknown"),
userEmail: user != null ? user.email : "", userEmail: user != null ? user.email : "",
date: r.date, date: r.date,
ip: r.ipAddress, ip: r.ipAddress,
type: r.type, type: r.type,
installationId: r.installationId,
}); });
}) })
); );

View File

@@ -1,6 +1,6 @@
<div class="container footer text-muted"> <div class="container footer text-muted">
<div class="row"> <div class="row">
<div class="col">&copy; {{ year }} Bitwarden Inc.</div> <div class="col">&copy; {{ year }}, Bitwarden Inc.</div>
<div class="col text-center"></div> <div class="col text-center"></div>
<div class="col text-right"> <div class="col text-right">
{{ "versionNumber" | i18n: version }} {{ "versionNumber" | i18n: version }}

View File

@@ -1,5 +1,5 @@
<router-outlet></router-outlet> <router-outlet></router-outlet>
<div class="container my-5 text-muted text-center"> <div class="container my-5 text-muted text-center">
&copy; {{ year }} Bitwarden Inc. <br /> &copy; {{ year }}, Bitwarden Inc. <br />
{{ "versionNumber" | i18n: version }} {{ "versionNumber" | i18n: version }}
</div> </div>

View File

@@ -114,6 +114,7 @@ import { EmergencyAccessTakeoverComponent } from "../settings/emergency-access-t
import { EmergencyAccessViewComponent } from "../settings/emergency-access-view.component"; import { EmergencyAccessViewComponent } from "../settings/emergency-access-view.component";
import { EmergencyAccessComponent } from "../settings/emergency-access.component"; import { EmergencyAccessComponent } from "../settings/emergency-access.component";
import { EmergencyAddEditComponent } from "../settings/emergency-add-edit.component"; import { EmergencyAddEditComponent } from "../settings/emergency-add-edit.component";
import { LinkSsoComponent } from "../settings/link-sso.component";
import { OrganizationPlansComponent } from "../settings/organization-plans.component"; import { OrganizationPlansComponent } from "../settings/organization-plans.component";
import { PaymentMethodComponent } from "../settings/payment-method.component"; import { PaymentMethodComponent } from "../settings/payment-method.component";
import { PaymentComponent } from "../settings/payment.component"; import { PaymentComponent } from "../settings/payment.component";
@@ -222,6 +223,7 @@ import { OrganizationBadgeModule } from "./vault/modules/organization-badge/orga
HintComponent, HintComponent,
ImportComponent, ImportComponent,
InactiveTwoFactorReportComponent, InactiveTwoFactorReportComponent,
LinkSsoComponent,
LockComponent, LockComponent,
LoginComponent, LoginComponent,
MasterPasswordPolicyComponent, MasterPasswordPolicyComponent,
@@ -381,6 +383,7 @@ import { OrganizationBadgeModule } from "./vault/modules/organization-badge/orga
HintComponent, HintComponent,
ImportComponent, ImportComponent,
InactiveTwoFactorReportComponent, InactiveTwoFactorReportComponent,
LinkSsoComponent,
LockComponent, LockComponent,
LoginComponent, LoginComponent,
MasterPasswordPolicyComponent, MasterPasswordPolicyComponent,

View File

@@ -53,7 +53,13 @@ import localeZhTw from "@angular/common/locales/zh-Hant";
import { NgModule } from "@angular/core"; import { NgModule } from "@angular/core";
import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { RouterModule } from "@angular/router"; import { RouterModule } from "@angular/router";
import { BadgeModule, ButtonModule, CalloutModule, MenuModule } from "@bitwarden/components"; import {
BadgeModule,
ButtonModule,
CalloutModule,
FormFieldModule,
MenuModule,
} from "@bitwarden/components";
import { InfiniteScrollModule } from "ngx-infinite-scroll"; import { InfiniteScrollModule } from "ngx-infinite-scroll";
import { ToastrModule } from "ngx-toastr"; import { ToastrModule } from "ngx-toastr";
@@ -126,6 +132,7 @@ registerLocaleData(localeZhTw, "zh-TW");
BadgeModule, BadgeModule,
ButtonModule, ButtonModule,
MenuModule, MenuModule,
FormFieldModule,
], ],
exports: [ exports: [
CommonModule, CommonModule,
@@ -136,6 +143,7 @@ registerLocaleData(localeZhTw, "zh-TW");
ReactiveFormsModule, ReactiveFormsModule,
RouterModule, RouterModule,
BadgeModule, BadgeModule,
FormFieldModule,
ButtonModule, ButtonModule,
CalloutModule, CalloutModule,
ToastrModule, ToastrModule,

View File

@@ -16,7 +16,7 @@
aria-hidden="true" aria-hidden="true"
></i> ></i>
</button> </button>
<h3 class="filter-title">&nbsp;{{ collectionsGrouping.name | i18n }}</h3> <h3 class="filter-title">{{ collectionsGrouping.name | i18n }}</h3>
</div> </div>
<ul id="collection-filters" *ngIf="!isCollapsed(collectionsGrouping)" class="filter-options"> <ul id="collection-filters" *ngIf="!isCollapsed(collectionsGrouping)" class="filter-options">
<ng-template #recursiveCollections let-collections> <ng-template #recursiveCollections let-collections>
@@ -51,7 +51,7 @@
class="bwi bwi-collection bwi-fw" class="bwi bwi-collection bwi-fw"
aria-hidden="true" aria-hidden="true"
></i ></i
>&nbsp;{{ c.node.name }} >{{ c.node.name }}
</button> </button>
</span> </span>
<ul <ul

View File

@@ -16,7 +16,9 @@
}" }"
></i> ></i>
</button> </button>
<h3 class="filter-title">&nbsp;{{ "folders" | i18n }}</h3> <h3 class="filter-title">
{{ "folders" | i18n }}
</h3>
<button <button
class="text-muted ml-auto add-button" class="text-muted ml-auto add-button"
(click)="addFolder()" (click)="addFolder()"
@@ -54,7 +56,7 @@
</button> </button>
<button class="filter-button" (click)="applyFilter(f.node)"> <button class="filter-button" (click)="applyFilter(f.node)">
<i *ngIf="f.children.length === 0" class="bwi bwi-fw bwi-folder" aria-hidden="true"></i <i *ngIf="f.children.length === 0" class="bwi bwi-fw bwi-folder" aria-hidden="true"></i
>&nbsp;{{ f.node.name }} >{{ f.node.name }}
</button> </button>
<button <button
class="edit-button" class="edit-button"

View File

@@ -14,7 +14,7 @@
<span class="filter-buttons"> <span class="filter-buttons">
<a href="#" routerLink="/create-organization" class="filter-button"> <a href="#" routerLink="/create-organization" class="filter-button">
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i> <i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
&nbsp;{{ "newOrganization" | i18n }} {{ "newOrganization" | i18n }}
</a> </a>
</span> </span>
</li> </li>
@@ -45,6 +45,14 @@
> >
&nbsp;{{ organizationGrouping.name | i18n }} &nbsp;{{ organizationGrouping.name | i18n }}
</button> </button>
<a
href="#"
routerLink="/create-organization"
class="text-muted ml-auto create-organization-link"
appA11yTitle="{{ 'newOrganization' | i18n }}"
>
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
</a>
</div> </div>
<ul id="organization-filters" *ngIf="!isCollapsed" class="filter-options"> <ul id="organization-filters" *ngIf="!isCollapsed" class="filter-options">
<li <li
@@ -67,14 +75,6 @@
</ng-container> </ng-container>
</span> </span>
</li> </li>
<li class="filter-option">
<span class="filter-buttons">
<a href="#" routerLink="/create-organization" class="filter-button">
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
&nbsp;{{ "newOrganization" | i18n }}
</a>
</span>
</li>
</ul> </ul>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'singleOrganizationAndPersonalOwnershipPolicies'"> <ng-container *ngSwitchCase="'singleOrganizationAndPersonalOwnershipPolicies'">
@@ -110,6 +110,15 @@
> >
&nbsp;{{ organizationGrouping.name | i18n }} &nbsp;{{ organizationGrouping.name | i18n }}
</button> </button>
<a
href="#"
routerLink="/create-organization"
class="text-muted ml-auto create-organization-link"
appA11yTitle="{{ 'newOrganization' | i18n }}"
*ngIf="!(displayMode === 'singleOrganizationPolicy')"
>
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
</a>
</div> </div>
<ul id="organization-filters" *ngIf="!isCollapsed" class="filter-options"> <ul id="organization-filters" *ngIf="!isCollapsed" class="filter-options">
<li class="filter-option" [ngClass]="{ active: activeFilter.myVaultOnly }"> <li class="filter-option" [ngClass]="{ active: activeFilter.myVaultOnly }">
@@ -140,14 +149,6 @@
</ng-container> </ng-container>
</span> </span>
</li> </li>
<li class="filter-option" *ngIf="!(displayMode === 'singleOrganizationPolicy')">
<span class="filter-buttons">
<a href="#" routerLink="/create-organization" class="filter-button">
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
&nbsp;{{ "newOrganization" | i18n }}
</a>
</span>
</li>
</ul> </ul>
</ng-container> </ng-container>
</ng-container> </ng-container>

View File

@@ -15,7 +15,9 @@
}" }"
></i> ></i>
</button> </button>
<h3>&nbsp;{{ "types" | i18n }}</h3> <h3>
{{ "types" | i18n }}
</h3>
</div> </div>
<ul id="type-filters" *ngIf="!isCollapsed" class="filter-options"> <ul id="type-filters" *ngIf="!isCollapsed" class="filter-options">
<li <li
@@ -24,14 +26,14 @@
> >
<span class="filter-buttons"> <span class="filter-buttons">
<button class="filter-button" (click)="applyFilter(cipherTypeEnum.Login)"> <button class="filter-button" (click)="applyFilter(cipherTypeEnum.Login)">
<i class="bwi bwi-fw bwi-globe" aria-hidden="true"></i>&nbsp;{{ "typeLogin" | i18n }} <i class="bwi bwi-fw bwi-globe" aria-hidden="true"></i>{{ "typeLogin" | i18n }}
</button> </button>
</span> </span>
</li> </li>
<li class="filter-option" [ngClass]="{ active: activeFilter.cipherType === cipherTypeEnum.Card }"> <li class="filter-option" [ngClass]="{ active: activeFilter.cipherType === cipherTypeEnum.Card }">
<span class="filter-buttons"> <span class="filter-buttons">
<button class="filter-button" (click)="applyFilter(cipherTypeEnum.Card)"> <button class="filter-button" (click)="applyFilter(cipherTypeEnum.Card)">
<i class="bwi bwi-fw bwi-credit-card" aria-hidden="true"></i>&nbsp;{{ "typeCard" | i18n }} <i class="bwi bwi-fw bwi-credit-card" aria-hidden="true"></i>{{ "typeCard" | i18n }}
</button> </button>
</span> </span>
</li> </li>
@@ -41,7 +43,7 @@
> >
<span class="filter-buttons"> <span class="filter-buttons">
<button class="filter-button" (click)="applyFilter(cipherTypeEnum.Identity)"> <button class="filter-button" (click)="applyFilter(cipherTypeEnum.Identity)">
<i class="bwi bwi-fw bwi-id-card" aria-hidden="true"></i>&nbsp;{{ "typeIdentity" | i18n }} <i class="bwi bwi-fw bwi-id-card" aria-hidden="true"></i>{{ "typeIdentity" | i18n }}
</button> </button>
</span> </span>
</li> </li>
@@ -51,9 +53,7 @@
> >
<span class="filter-buttons"> <span class="filter-buttons">
<button class="filter-button" (click)="applyFilter(cipherTypeEnum.SecureNote)"> <button class="filter-button" (click)="applyFilter(cipherTypeEnum.SecureNote)">
<i class="bwi bwi-fw bwi-sticky-note" aria-hidden="true"></i>&nbsp;{{ <i class="bwi bwi-fw bwi-sticky-note" aria-hidden="true"></i>{{ "typeSecureNote" | i18n }}
"typeSecureNote" | i18n
}}
</button> </button>
</span> </span>
</li> </li>

View File

@@ -25,7 +25,17 @@ export class VaultFilterComponent extends BaseVaultFilterComponent {
} }
searchTextChanged() { searchTextChanged() {
this.onSearchTextChanged.emit(this.searchText.normalize("NFD").replace(/[\u0300-\u036f]/g, "")); this.onSearchTextChanged.emit(this.searchText);
}
// This method exists because the vault component gets its data mixed up during the initial sync on first login. It looks for data before the sync is complete.
// It should be removed as soon as doing so makes sense.
async reloadOrganizations() {
this.organizations = await this.vaultFilterService.buildOrganizations();
this.activePersonalOwnershipPolicy =
await this.vaultFilterService.checkForPersonalOwnershipPolicy();
this.activeSingleOrganizationPolicy =
await this.vaultFilterService.checkForSingleOrganizationPolicy();
} }
async initCollections() { async initCollections() {

View File

@@ -12,7 +12,6 @@ import { SharedModule } from "../shared.module";
import { CollectionFilterComponent } from "./components/collection-filter.component"; import { CollectionFilterComponent } from "./components/collection-filter.component";
import { FolderFilterComponent } from "./components/folder-filter.component"; import { FolderFilterComponent } from "./components/folder-filter.component";
import { LinkSsoComponent } from "./components/link-sso.component";
import { OrganizationFilterComponent } from "./components/organization-filter.component"; import { OrganizationFilterComponent } from "./components/organization-filter.component";
import { OrganizationOptionsComponent } from "./components/organization-options.component"; import { OrganizationOptionsComponent } from "./components/organization-options.component";
import { StatusFilterComponent } from "./components/status-filter.component"; import { StatusFilterComponent } from "./components/status-filter.component";
@@ -29,7 +28,6 @@ import { VaultFilterComponent } from "./vault-filter.component";
OrganizationOptionsComponent, OrganizationOptionsComponent,
StatusFilterComponent, StatusFilterComponent,
TypeFilterComponent, TypeFilterComponent,
LinkSsoComponent,
], ],
exports: [VaultFilterComponent], exports: [VaultFilterComponent],
providers: [ providers: [

View File

@@ -58,6 +58,7 @@ export class IndividualVaultComponent implements OnInit, OnDestroy {
updateKeyModalRef: ViewContainerRef; updateKeyModalRef: ViewContainerRef;
favorites = false; favorites = false;
type: CipherType = null;
folderId: string = null; folderId: string = null;
collectionId: string = null; collectionId: string = null;
organizationId: string = null; organizationId: string = null;
@@ -326,7 +327,7 @@ export class IndividualVaultComponent implements OnInit, OnDestroy {
async addCipher() { async addCipher() {
const component = await this.editCipher(null); const component = await this.editCipher(null);
component.type = this.activeFilter.cipherType; component.type = this.type;
component.folderId = this.folderId === "none" ? null : this.folderId; component.folderId = this.folderId === "none" ? null : this.folderId;
if (this.activeFilter.selectedCollectionId != null) { if (this.activeFilter.selectedCollectionId != null) {
const collection = this.filterComponent.collections.fullList.filter( const collection = this.filterComponent.collections.fullList.filter(
@@ -398,7 +399,7 @@ export class IndividualVaultComponent implements OnInit, OnDestroy {
if (queryParams == null) { if (queryParams == null) {
queryParams = { queryParams = {
favorites: this.favorites ? true : null, favorites: this.favorites ? true : null,
type: this.activeFilter.cipherType, type: this.type,
folderId: this.folderId, folderId: this.folderId,
collectionId: this.collectionId, collectionId: this.collectionId,
deleted: this.deleted ? true : null, deleted: this.deleted ? true : null,

View File

@@ -14,62 +14,50 @@
#form #form
(ngSubmit)="submit()" (ngSubmit)="submit()"
[appApiAction]="formPromise" [appApiAction]="formPromise"
ngNativeValidate [formGroup]="formData"
> >
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<div class="form-group"> <bit-form-field>
<label for="name">{{ "organizationName" | i18n }}</label> <bit-label>{{ "organizationName" | i18n }}</bit-label>
<input <input bitInput type="text" formControlName="name" />
id="name" </bit-form-field>
class="form-control"
type="text" <bit-form-field>
name="Name" <bit-label>{{ "billingEmail" | i18n }}</bit-label>
[(ngModel)]="org.name" <input bitInput type="email" formControlName="billingEmail" />
[disabled]="selfHosted" </bit-form-field>
/>
</div> <bit-form-field>
<div class="form-group"> <bit-label>{{ "businessName" | i18n }}</bit-label>
<label for="billingEmail">{{ "billingEmail" | i18n }}</label> <input bitInput type="text" formControlName="businessName" />
<input </bit-form-field>
id="billingEmail"
class="form-control" <bit-form-field>
type="text" <bit-label>{{ "identifier" | i18n }}</bit-label>
name="BillingEmail" <input bitInput type="text" formControlName="identifier" />
[(ngModel)]="org.billingEmail" </bit-form-field>
[disabled]="selfHosted || !canManageBilling"
/>
</div>
<div class="form-group">
<label for="businessName">{{ "businessName" | i18n }}</label>
<input
id="businessName"
class="form-control"
type="text"
name="BusinessName"
[(ngModel)]="org.businessName"
[disabled]="selfHosted || !canManageBilling"
/>
</div>
<div class="form-group">
<label for="identifier">{{ "identifier" | i18n }}</label>
<input
id="identifier"
class="form-control"
type="text"
name="Identifier"
[(ngModel)]="org.identifier"
/>
</div>
</div> </div>
<div class="col-6"> <div class="col-6">
<app-avatar data="{{ org.name }}" dynamic="true" size="75" fontSize="35"></app-avatar> <app-avatar
[data]="formData.get('name').value"
dynamic="true"
size="75"
fontSize="35"
></app-avatar>
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading"> <button
type="submit"
bit-button
buttonType="primary"
class="btn-submit"
[disabled]="form.loading"
>
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i> <i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
<span>{{ "save" | i18n }}</span> <span>{{ "save" | i18n }}</span>
</button> </button>
<bit-error-summary *ngIf="showErrorSummary" [formGroup]="formData"></bit-error-summary>
</form> </form>
<ng-container *ngIf="canUseApi"> <ng-container *ngIf="canUseApi">
<div class="secondary-header border-0 mb-0"> <div class="secondary-header border-0 mb-0">

View File

@@ -1,4 +1,5 @@
import { Component, ViewChild, ViewContainerRef } from "@angular/core"; import { Component, ViewChild, ViewContainerRef } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { ModalService } from "jslib-angular/services/modal.service"; import { ModalService } from "jslib-angular/services/modal.service";
@@ -41,10 +42,19 @@ export class AccountComponent {
org: OrganizationResponse; org: OrganizationResponse;
formPromise: Promise<any>; formPromise: Promise<any>;
taxFormPromise: Promise<any>; taxFormPromise: Promise<any>;
showErrorSummary = false;
private organizationId: string; private organizationId: string;
formData = this.formBuilder.group({
name: ["", [Validators.required]],
billingEmail: ["", [Validators.required, Validators.email]],
businessName: [],
identifier: [],
});
constructor( constructor(
private formBuilder: FormBuilder,
private modalService: ModalService, private modalService: ModalService,
private apiService: ApiService, private apiService: ApiService,
private i18nService: I18nService, private i18nService: I18nService,
@@ -60,6 +70,12 @@ export class AccountComponent {
async ngOnInit() { async ngOnInit() {
this.selfHosted = this.platformUtilsService.isSelfHost(); this.selfHosted = this.platformUtilsService.isSelfHost();
if (this.selfHosted) {
this.formData.disable();
} else {
this.formData.enable();
}
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId; this.organizationId = params.organizationId;
this.canManageBilling = ( this.canManageBilling = (
@@ -68,6 +84,13 @@ export class AccountComponent {
try { try {
this.org = await this.apiService.getOrganization(this.organizationId); this.org = await this.apiService.getOrganization(this.organizationId);
this.canUseApi = this.org.useApi; this.canUseApi = this.org.useApi;
this.formData.setValue({
name: this.org.name,
billingEmail: this.org.billingEmail,
businessName: this.org.businessName,
identifier: this.org.identifier,
});
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
} }
@@ -76,12 +99,19 @@ export class AccountComponent {
} }
async submit() { async submit() {
this.formData.markAllAsTouched();
this.showErrorSummary = true;
if (!this.formData.valid) {
return;
}
try { try {
const request = new OrganizationUpdateRequest(); const request = new OrganizationUpdateRequest();
request.name = this.org.name; request.name = this.formData.get("name").value;
request.businessName = this.org.businessName; request.businessName = this.formData.get("businessName").value;
request.billingEmail = this.org.billingEmail; request.billingEmail = this.formData.get("billingEmail").value;
request.identifier = this.org.identifier; request.identifier = this.formData.get("identifier").value;
// Backfill pub/priv key if necessary // Backfill pub/priv key if necessary
if (!this.org.hasPublicAndPrivateKeys) { if (!this.org.hasPublicAndPrivateKeys) {

View File

@@ -3,10 +3,7 @@ import { ActivatedRoute } from "@angular/router";
import { ModalService } from "jslib-angular/services/modal.service"; import { ModalService } from "jslib-angular/services/modal.service";
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from "jslib-common/abstractions/api.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { MessagingService } from "jslib-common/abstractions/messaging.service"; import { MessagingService } from "jslib-common/abstractions/messaging.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service"; import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service"; import { StateService } from "jslib-common/abstractions/state.service";
import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType"; import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType";
@@ -25,21 +22,9 @@ export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent {
messagingService: MessagingService, messagingService: MessagingService,
policyService: PolicyService, policyService: PolicyService,
private route: ActivatedRoute, private route: ActivatedRoute,
stateService: StateService, stateService: StateService
platformUtilsService: PlatformUtilsService,
i18nService: I18nService,
logService: LogService
) { ) {
super( super(apiService, modalService, messagingService, policyService, stateService);
apiService,
modalService,
messagingService,
policyService,
stateService,
platformUtilsService,
i18nService,
logService
);
} }
async ngOnInit() { async ngOnInit() {

View File

@@ -1,7 +1,7 @@
<form #form (ngSubmit)="load()" [appApiAction]="formPromise" class="container" ngNativeValidate> <form #form (ngSubmit)="load()" [appApiAction]="formPromise" class="container" ngNativeValidate>
<div class="row justify-content-center mt-5"> <div class="row justify-content-center mt-5">
<div class="col-12"> <div class="col-12">
<h1 class="lead text-center mb-4">Bitwarden Send</h1> <p class="lead text-center mb-4">Bitwarden Send</p>
</div> </div>
<div class="col-12 text-center" *ngIf="creatorIdentifier != null"> <div class="col-12 text-center" *ngIf="creatorIdentifier != null">
<p>{{ "sendCreatorIdentifier" | i18n: creatorIdentifier }}</p> <p>{{ "sendCreatorIdentifier" | i18n: creatorIdentifier }}</p>

View File

@@ -307,9 +307,6 @@ export class EventService {
case EventType.Organization_DisabledKeyConnector: case EventType.Organization_DisabledKeyConnector:
msg = humanReadableMsg = this.i18nService.t("disabledKeyConnector"); msg = humanReadableMsg = this.i18nService.t("disabledKeyConnector");
break; break;
case EventType.Organization_SponsorshipsSynced:
msg = humanReadableMsg = this.i18nService.t("sponsorshipsSynced");
break;
// Policies // Policies
case EventType.Policy_Updated: { case EventType.Policy_Updated: {
msg = this.i18nService.t("modifiedPolicyId", this.formatPolicyId(ev)); msg = this.i18nService.t("modifiedPolicyId", this.formatPolicyId(ev));

View File

@@ -3,6 +3,7 @@ import { Component } from "@angular/core";
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from "jslib-common/abstractions/api.service";
import { LogService } from "jslib-common/abstractions/log.service"; import { LogService } from "jslib-common/abstractions/log.service";
import { OrganizationConnectionType } from "jslib-common/enums/organizationConnectionType"; import { OrganizationConnectionType } from "jslib-common/enums/organizationConnectionType";
import { Utils } from "jslib-common/misc/utils";
import { BillingSyncConfigApi } from "jslib-common/models/api/billingSyncConfigApi"; import { BillingSyncConfigApi } from "jslib-common/models/api/billingSyncConfigApi";
import { BillingSyncConfigRequest } from "jslib-common/models/request/billingSyncConfigRequest"; import { BillingSyncConfigRequest } from "jslib-common/models/request/billingSyncConfigRequest";
import { OrganizationConnectionRequest } from "jslib-common/models/request/organizationConnectionRequest"; import { OrganizationConnectionRequest } from "jslib-common/models/request/organizationConnectionRequest";

View File

@@ -55,40 +55,6 @@
</div> </div>
</li> </li>
</ul> </ul>
<form *ngIf="!loading" #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
<div class="row">
<div class="col-12">
<h2 class="mt-5 spaced-header">
{{ "deviceVerification" | i18n }}
</h2>
<div class="form-group">
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
id="enableDeviceVerification"
name="enableDeviceVerification"
disabled="{{ !isDeviceVerificationSectionEnabled }}"
[(ngModel)]="enableDeviceVerification"
/>
<label class="form-check-label" for="enableDeviceVerification">
{{ "enableDeviceVerification" | i18n }}
</label>
</div>
<small class="form-text text-muted">{{ "deviceVerificationDesc" | i18n }}</small>
</div>
<button
type="submit"
class="btn btn-primary btn-submit"
[disabled]="form.loading"
*ngIf="isDeviceVerificationSectionEnabled"
>
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
<span>{{ "save" | i18n }}</span>
</button>
</div>
</div>
</form>
<ng-template #authenticatorTemplate></ng-template> <ng-template #authenticatorTemplate></ng-template>
<ng-template #recoveryTemplate></ng-template> <ng-template #recoveryTemplate></ng-template>

View File

@@ -3,15 +3,11 @@ import { Component, OnInit, Type, ViewChild, ViewContainerRef } from "@angular/c
import { ModalRef } from "jslib-angular/components/modal/modal.ref"; import { ModalRef } from "jslib-angular/components/modal/modal.ref";
import { ModalService } from "jslib-angular/services/modal.service"; import { ModalService } from "jslib-angular/services/modal.service";
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from "jslib-common/abstractions/api.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { MessagingService } from "jslib-common/abstractions/messaging.service"; import { MessagingService } from "jslib-common/abstractions/messaging.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service"; import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service"; import { StateService } from "jslib-common/abstractions/state.service";
import { PolicyType } from "jslib-common/enums/policyType"; import { PolicyType } from "jslib-common/enums/policyType";
import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType"; import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType";
import { DeviceVerificationRequest } from "jslib-common/models/request/DeviceVerificationRequest";
import { TwoFactorProviders } from "jslib-common/services/twoFactor.service"; import { TwoFactorProviders } from "jslib-common/services/twoFactor.service";
import { TwoFactorAuthenticatorComponent } from "./two-factor-authenticator.component"; import { TwoFactorAuthenticatorComponent } from "./two-factor-authenticator.component";
@@ -43,32 +39,18 @@ export class TwoFactorSetupComponent implements OnInit {
canAccessPremium: boolean; canAccessPremium: boolean;
showPolicyWarning = false; showPolicyWarning = false;
loading = true; loading = true;
enableDeviceVerification: boolean;
isDeviceVerificationSectionEnabled: boolean;
modal: ModalRef; modal: ModalRef;
formPromise: Promise<any>;
constructor( constructor(
protected apiService: ApiService, protected apiService: ApiService,
protected modalService: ModalService, protected modalService: ModalService,
protected messagingService: MessagingService, protected messagingService: MessagingService,
protected policyService: PolicyService, protected policyService: PolicyService,
private stateService: StateService, private stateService: StateService
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private logService: LogService
) {} ) {}
async ngOnInit() { async ngOnInit() {
this.canAccessPremium = await this.stateService.getCanAccessPremium(); this.canAccessPremium = await this.stateService.getCanAccessPremium();
try {
const deviceVerificationSettings = await this.apiService.getDeviceVerificationSettings();
this.isDeviceVerificationSectionEnabled =
deviceVerificationSettings.isDeviceVerificationSectionEnabled;
this.enableDeviceVerification = deviceVerificationSettings.unknownDeviceVerificationEnabled;
} catch (e) {
this.logService.error(e);
}
for (const key in TwoFactorProviders) { for (const key in TwoFactorProviders) {
// eslint-disable-next-line // eslint-disable-next-line
@@ -204,37 +186,4 @@ export class TwoFactorSetupComponent implements OnInit {
this.showPolicyWarning = false; this.showPolicyWarning = false;
} }
} }
async submit() {
try {
if (this.enableDeviceVerification) {
const email = await this.stateService.getEmail();
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t(
"areYouSureYouWantToEnableDeviceVerificationTheVerificationCodeEmailsWillArriveAtX",
email
),
this.i18nService.t("deviceVerification"),
this.i18nService.t("yes"),
this.i18nService.t("no"),
"warning"
);
if (!confirmed) {
return;
}
}
this.formPromise = this.apiService.putDeviceVerificationSettings(
new DeviceVerificationRequest(this.enableDeviceVerification)
);
await this.formPromise;
this.platformUtilsService.showToast(
"success",
null,
this.i18nService.t("updatedDeviceVerification")
);
} catch (e) {
this.logService.error(e);
}
}
} }

View File

@@ -5041,9 +5041,6 @@
"message": "Last Sync", "message": "Last Sync",
"Description": "Used as a prefix to indicate the last time a sync occured. Example \"Last sync 1968-11-16 00:00:00\"" "Description": "Used as a prefix to indicate the last time a sync occured. Example \"Last sync 1968-11-16 00:00:00\""
}, },
"sponsorshipsSynced": {
"message": "Self-hosted sponsorships synced."
},
"billingManagedByProvider": { "billingManagedByProvider": {
"message": "Managed by $PROVIDER$", "message": "Managed by $PROVIDER$",
"placeholders": { "placeholders": {
@@ -5070,24 +5067,18 @@
"apiAccessToken": { "apiAccessToken": {
"message": "API Access Token" "message": "API Access Token"
}, },
"deviceVerification": { "inputRequired": {
"message": "Device Verification" "message": "Input is required."
}, },
"enableDeviceVerification": { "inputEmail": {
"message": "Enable Device Verification" "message": "Input is not an email-address."
}, },
"deviceVerificationDesc": { "fieldsNeedAttention": {
"message": "When enabled, verification codes are sent to your email address when logging in from an unrecognized device" "message": "$COUNT$ field(s) above need your attention.",
},
"updatedDeviceVerification": {
"message": "Updated Device Verification"
},
"areYouSureYouWantToEnableDeviceVerificationTheVerificationCodeEmailsWillArriveAtX": {
"message": "Are you sure you want to enable Device Verification? The verification code emails will arrive at: $EMAIL$",
"placeholders": { "placeholders": {
"email": { "count": {
"content": "$1", "content": "$1",
"example": "My Email" "example": "4"
} }
} }
} }

View File

@@ -14,6 +14,14 @@
font-size: $font-size-base; font-size: $font-size-base;
} }
a.create-organization-link {
&:hover {
@include themify($themes) {
color: themed("iconHover") !important;
}
}
}
button { button {
@extend .no-btn; @extend .no-btn;
} }