1
0
mirror of https://github.com/bitwarden/web synced 2025-12-10 05:13:40 +00:00

Compare commits

..

27 Commits

Author SHA1 Message Date
Vince Grassia
3f5f3dc5c8 Bump version 2021-11-10 14:06:14 -05:00
Justin Baur
c01d95f870 Update payment info (#1274)
* Added manual routing

* Add additional copy for free trial

* Revert

* Fix formatting

* Switch text to be on the top of the payment info

* Update to put text at top of the screen

(cherry picked from commit b164a39abc)
2021-11-10 14:04:16 -05:00
Matt Gibson
7b58b66e17 Fix repeat ng insert on safari (#1270)
(cherry picked from commit cf5823fe71)
2021-11-01 17:15:11 -04:00
Matt Gibson
95b9e6fb24 bump version 2021-11-01 15:34:57 -04:00
Matt Gibson
52c057555c Show upgrade plan button for free orgs. (#1269)
* Show upgrade plan button for free orgs.

* Add families plan callout for subscription upgrade

(cherry picked from commit bb0b5f2d87)
2021-11-01 15:32:44 -04:00
Joseph Flinn
a6274fa56e Adding fixes from last night's release (#1263)
(cherry picked from commit 523b18156c)
2021-10-27 13:09:50 -07:00
Matt Gibson
c1ede75a98 Update jslib for permissions changes 2021-10-27 14:16:54 -04:00
Matt Gibson
16cf1c4a47 2.24.1 2021-10-27 11:04:22 -04:00
Matt Gibson
477bb997dc Null Check subscription prior to use (#1264)
(cherry picked from commit 383c29c761)
2021-10-27 11:04:10 -04:00
Joseph Flinn
9e3d45da6c changing how we checkout the new release branch 2021-10-26 20:48:03 -07:00
github-actions[bot]
8892553e30 Autosync the updated translations (#1259)
Co-authored-by: github-actions <>
(cherry picked from commit a6a34788a8)
2021-10-26 15:10:35 -07:00
Joseph Flinn
95ff586a47 enabling the new release branch to push its docker images (#1258)
(cherry picked from commit 381ec7af67)
2021-10-26 14:21:58 -07:00
Joseph Flinn
342e09da9e Version Bump 2.24.0
(cherry picked from commit c589728506)
2021-10-26 13:48:47 -07:00
Joseph Flinn
32cecf6086 Change release branch constraints (#1248)
* updating the release branch constraints

* updating the self host docker image build and release with the new release branch

* renaming the release job for selfhost docker release

* removing unneeded line

* removing the master branch release ci code execution

* updating some verbiage

(cherry picked from commit 618f950cae)
2021-10-22 09:31:39 -07:00
Matt Gibson
b122d24350 Update jslib 2021-10-20 17:26:50 -04:00
Matt Gibson
a620a3f84c Limit collection actions presented to permitted (#1247)
* Limit collection actions presented to permitted

* Revert useless move

* Limit vault view to editable ciphers and collections

* Update jslib

* PR review

(cherry picked from commit 9dd859af7a)
2021-10-20 17:21:29 -04:00
Thomas Rittson
3d30495ffb Fix btn-link colors in dark mode (#1246) 2021-10-20 07:50:25 +10:00
Kyle Spearrin
bb03595d02 New Crowdin updates (#1242)
* New translations messages.json (Romanian)

* New translations messages.json (Korean)

* New translations messages.json (Vietnamese)

* New translations messages.json (Chinese Traditional)

* New translations messages.json (Chinese Simplified)

* New translations messages.json (Ukrainian)

* New translations messages.json (Turkish)

* New translations messages.json (French)

* New translations messages.json (Serbian (Cyrillic))

* New translations messages.json (Slovenian)

* New translations messages.json (Slovak)

* New translations messages.json (Russian)

* New translations messages.json (Portuguese)

* New translations messages.json (Polish)

* New translations messages.json (Dutch)

* New translations messages.json (Swedish)

* New translations messages.json (Japanese)

* New translations messages.json (Czech)

* New translations messages.json (Italian)

* New translations messages.json (Spanish)

* New translations messages.json (Afrikaans)

* New translations messages.json (Bulgarian)

* New translations messages.json (Catalan)

* New translations messages.json (Belarusian)

* New translations messages.json (Danish)

* New translations messages.json (German)

* New translations messages.json (Greek)

* New translations messages.json (Finnish)

* New translations messages.json (Hebrew)

* New translations messages.json (Hungarian)

* New translations messages.json (English, United Kingdom)

* New translations messages.json (Serbian (Latin))

* New translations messages.json (Norwegian Bokmal)

* New translations messages.json (Kannada)

* New translations messages.json (Sinhala)

* New translations messages.json (Malayalam)

* New translations messages.json (Filipino)

* New translations messages.json (Esperanto)

* New translations messages.json (Bengali)

* New translations messages.json (Hindi)

* New translations messages.json (Azerbaijani)

* New translations messages.json (Latvian)

* New translations messages.json (Estonian)

* New translations messages.json (Norwegian Nynorsk)

* New translations messages.json (Croatian)

* New translations messages.json (Indonesian)

* New translations messages.json (Portuguese, Brazilian)

* New translations messages.json (English, India)
2021-10-19 12:26:39 -04:00
github-actions[bot]
ff11d0468c Autosync the updated translations (#1241)
Co-authored-by: github-actions <>
2021-10-19 12:26:28 -04:00
Matt Gibson
825b174007 Remove unnecessary fallbacks (#1245)
Web is in lock-step to server version. We do not need fallbacks
since we're sure the server version will support collection permissions split.

(cherry picked from commit 1de569e64d)
2021-10-19 09:08:39 -04:00
Matt Gibson
39690a01ac Add user uses to new permission model (#1228)
(cherry picked from commit 3ee61fef96)
2021-10-18 14:53:25 -04:00
Matt Portune
905e39d060 Mobile WebAuthn connector updates (#1236)
* support for returning to app via button press and updated mobile connector UI

* added client-driven header text and fixed lint issues
2021-10-15 10:35:23 -04:00
Oscar Hinton
9f83899480 Remove max from minutes in vault timeout input (#1239)
(cherry picked from commit db9ab9f51e)
2021-10-14 15:55:13 +02:00
Oscar Hinton
a99d38a2f3 Bump jsib (#1231) (#1238) 2021-10-14 14:10:36 +02:00
Oscar Hinton
5dccf54611 Prevent disabling single org when max vault timeout policy is enabled (#1230)
(cherry picked from commit c3a910e785)
2021-10-14 09:11:11 +02:00
Oscar Hinton
ad872f4d15 Fix sso copy buttons not behaving correctly (#1234)
(cherry picked from commit 4b4b5910e3)
2021-10-14 08:49:56 +02:00
Oscar Hinton
247429ef37 Bump jsib (#1231)
(cherry picked from commit 471490f14f)
2021-10-12 14:52:27 +02:00
525 changed files with 39787 additions and 59017 deletions

View File

@@ -1,4 +1,3 @@
* *
!docker/*
!build/* !build/*
!entrypoint.sh !entrypoint.sh

View File

@@ -12,7 +12,7 @@ insert_final_newline = true
[*.{js,ts,scss,html}] [*.{js,ts,scss,html}]
charset = utf-8 charset = utf-8
indent_style = space indent_style = space
indent_size = 2 indent_size = 4
[*.{ts}] [*.{ts}]
quote_type = single quote_type = single

View File

@@ -1,2 +0,0 @@
# Apply Prettier https://github.com/bitwarden/web/pull/1347
56477eb39cfd8a73c9920577d24d75fed36e2cf5

4
.gitattributes vendored
View File

@@ -1 +1,3 @@
* text=auto eol=lf *.sh eol=lf
.dockerignore eol=lf
dockerfile eol=lf

View File

@@ -1,32 +0,0 @@
## Type of change
- [ ] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other
## Objective
<!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding-->
## Code changes
<!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes-->
<!--Also refer to any related changes or PRs in other repositories-->
- **file.ext:** Description of what was changed and why
## Screenshots
<!--Required for any UI changes. Delete if not applicable-->
## Testing requirements
<!--What functionality requires testing by QA? This includes testing new behavior and regression testing-->
## Before you submit
- [ ] I have checked for **linting** errors (`npm run lint`) (required)
- [ ] This change requires a **documentation update** (notify the documentation team)
- [ ] This change has particular **deployment requirements** (notify the DevOps team)

View File

@@ -9,8 +9,8 @@ on:
required: false required: false
push: push:
branches-ignore: branches-ignore:
- "l10n_master" - 'l10n_master'
- "gh-pages" - 'gh-pages'
jobs: jobs:
cloc: cloc:
@@ -28,6 +28,7 @@ jobs:
- name: Print lines of code - name: Print lines of code
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
setup: setup:
name: Setup name: Setup
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -39,7 +40,9 @@ jobs:
- name: Get GitHub sha as version - name: Get GitHub sha as version
id: version id: version
run: echo "::set-output name=value::${GITHUB_SHA:0:7}" run: |
echo "::set-output name=value::${GITHUB_SHA:0:7}"
build-oss-selfhost: build-oss-selfhost:
name: Build OSS zip name: Build OSS zip
@@ -51,13 +54,17 @@ jobs:
- name: Set up Node - name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with: with:
node-version: "16" node-version: '14'
- name: Update NPM
run: |
npm install -g npm@7
- name: Cache npm - name: Cache npm
id: npm-cache id: npm-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
with: with:
path: "~/.npm" path: '~/.npm'
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Print environment - name: Print environment
@@ -88,6 +95,7 @@ jobs:
path: ./web-${{ env._VERSION }}-selfhosted-open-source.zip path: ./web-${{ env._VERSION }}-selfhosted-open-source.zip
if-no-files-found: error if-no-files-found: error
build-cloud: build-cloud:
name: Build Cloud zip name: Build Cloud zip
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -98,13 +106,17 @@ jobs:
- name: Set up Node - name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with: with:
node-version: "16" node-version: '14'
- name: Update NPM
run: |
npm install -g npm@7
- name: Cache npm - name: Cache npm
id: npm-cache id: npm-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
with: with:
path: "~/.npm" path: '~/.npm'
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Print environment - name: Print environment
@@ -135,6 +147,7 @@ jobs:
path: ./web-${{ env._VERSION }}-cloud-COMMERCIAL.zip path: ./web-${{ env._VERSION }}-cloud-COMMERCIAL.zip
if-no-files-found: error if-no-files-found: error
build-commercial-selfhost: build-commercial-selfhost:
name: Build SelfHost Docker image name: Build SelfHost Docker image
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -145,13 +158,17 @@ jobs:
- name: Set up Node - name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with: with:
node-version: "16" node-version: '14'
- name: Update NPM
run: |
npm install -g npm@7
- name: Cache npm - name: Cache npm
id: npm-cache id: npm-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
with: with:
path: "~/.npm" path: '~/.npm'
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Print environment - name: Print environment
@@ -165,7 +182,7 @@ jobs:
echo "GitHub event: $GITHUB_EVENT" echo "GitHub event: $GITHUB_EVENT"
- name: Setup DCT - name: Setup DCT
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix' if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/release'
id: setup-dct id: setup-dct
uses: bitwarden/gh-actions/setup-docker-trust@a8c384a05a974c05c48374c818b004be221d43ff uses: bitwarden/gh-actions/setup-docker-trust@a8c384a05a974c05c48374c818b004be221d43ff
with: with:
@@ -211,12 +228,12 @@ jobs:
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
run: docker tag bitwarden/web bitwarden/web:dev run: docker tag bitwarden/web bitwarden/web:dev
- name: Tag hotfix branch - name: Tag release branch
if: github.ref == 'refs/heads/hotfix' if: github.ref == 'refs/heads/release'
run: docker tag bitwarden/web bitwarden/web:hotfix run: docker tag bitwarden/web bitwarden/web:latest
- name: List Docker images - name: List Docker images
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix' if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/release'
run: docker images run: docker images
- name: Push rc image - name: Push rc image
@@ -233,17 +250,18 @@ jobs:
DOCKER_CONTENT_TRUST: 1 DOCKER_CONTENT_TRUST: 1
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }} DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
- name: Push hotfix image - name: Push latest image
if: github.ref == 'refs/heads/hotfix' if: github.ref == 'refs/heads/release'
run: docker push bitwarden/web:hotfix run: docker push bitwarden/web:latest
env: env:
DOCKER_CONTENT_TRUST: 1 DOCKER_CONTENT_TRUST: 1
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }} DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
- name: Log out of Docker - name: Log out of Docker
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix' if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/release'
run: docker logout run: docker logout
build-qa: build-qa:
name: Build Docker images for QA environment name: Build Docker images for QA environment
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -251,13 +269,17 @@ jobs:
- name: Set up Node - name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with: with:
node-version: "16" node-version: '14'
- name: Update NPM
run: |
npm install -g npm@7
- name: Cache npm - name: Cache npm
id: npm-cache id: npm-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
with: with:
path: "~/.npm" path: '~/.npm'
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Print environment - name: Print environment
@@ -307,7 +329,7 @@ jobs:
- name: Get image tag - name: Get image tag
id: image-tag id: image-tag
run: | run: |
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") IMAGE_TAG=$(echo "$GITHUB_REF" | awk '{split($0, a, "/"); print a[3];}')
TAG_EXTENSION=${{ github.event.inputs.custom_tag_extension }} TAG_EXTENSION=${{ github.event.inputs.custom_tag_extension }}
if [[ $TAG_EXTENSION ]]; then if [[ $TAG_EXTENSION ]]; then
@@ -339,6 +361,7 @@ jobs:
- name: Log out of Docker - name: Log out of Docker
run: docker logout run: docker logout
windows: windows:
name: Test code on Windows name: Test code on Windows
runs-on: windows-2019 runs-on: windows-2019
@@ -346,7 +369,7 @@ jobs:
- name: Set up NuGet - name: Set up NuGet
uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1 uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1
with: with:
nuget-version: "latest" nuget-version: 'latest'
- name: Set up MSBuild - name: Set up MSBuild
uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d
@@ -355,13 +378,17 @@ jobs:
id: npm-cache id: npm-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
with: with:
path: "~/.npm" path: '~/.npm'
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Set up Node - name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with: with:
node-version: "16" node-version: '14'
- name: Update NPM
run: |
npm install -g npm@7
- name: Print environment - name: Print environment
run: | run: |
@@ -382,112 +409,8 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Run linter - name: NPM install
run: npm run lint run: npm ci
- name: NPM build - name: NPM build
run: npm run build:bit:cloud run: npm run build:bit:cloud
crowdin-push:
name: Crowdin Push
if: github.ref == 'refs/heads/master'
needs:
- build-oss-selfhost
- build-cloud
- build-commercial-selfhost
- build-qa
runs-on: ubuntu-20.04
env:
_CROWDIN_PROJECT_ID: "308189"
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
- name: Login to Azure
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
with:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Retrieve secrets
id: retrieve-secrets
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
with:
keyvault: "bitwarden-prod-kv"
secrets: "crowdin-api-token"
- name: Upload Sources
uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea # v1.3.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }}
with:
config: crowdin.yml
crowdin_branch_name: master
upload_sources: true
upload_translations: false
check-failures:
name: Check for failures
if: always()
runs-on: ubuntu-20.04
needs:
- cloc
- setup
- build-oss-selfhost
- build-cloud
- build-commercial-selfhost
- build-qa
- crowdin-push
- windows
steps:
- name: Check if any job failed
if: ${{ (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/rc') }}
env:
CLOC_STATUS: ${{ needs.cloc.result }}
SETUP_STATUS: ${{ needs.setup.result }}
BUILD_OSS_SELFHOST_STATUS: ${{ needs.build-oss-selfhost.result }}
BUILD_CLOUD_STATUS: ${{ needs.build-cloud.result }}
BUILD_COMMERCIAL_SELFHOST_STATUS: ${{ needs.build-commercial-selfhost.result }}
BUILD_QA_STATUS: ${{ needs.build-qa.result }}
CROWDIN_PUSH_STATUS: ${{ needs.crowdin-push.result }}
WINDOWS_STATUS: ${{ needs.windows.result }}
run: |
if [ "$CLOC_STATUS" = "failure" ]; then
exit 1
elif [ "$SETUP_STATUS" = "failure" ]; then
exit 1
elif [ "$BUILD_OSS_SELFHOST_STATUS" = "failure" ]; then
exit 1
elif [ "$BUILD_CLOUD_STATUS" = "failure" ]; then
exit 1
elif [ "$BUILD_COMMERCIAL_SELFHOST_STATUS" = "failure" ]; then
exit 1
elif [ "$BUILD_QA_STATUS" = "failure" ]; then
exit 1
elif [ "$CROWDIN_PUSH_STATUS" = "failure" ]; then
exit 1
elif [ "$WINDOWS_STATUS" = "failure" ]; then
exit 1
fi
- name: Login to Azure - Prod Subscription
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
if: failure()
with:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Retrieve secrets
id: retrieve-secrets
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
if: failure()
with:
keyvault: "bitwarden-prod-kv"
secrets: "devops-alerts-slack-webhook-url"
- name: Notify Slack on failure
uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2
if: failure()
env:
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
with:
status: ${{ job.status }}

View File

@@ -1,15 +1,15 @@
--- ---
name: Crowdin Pull name: Crowdin Sync
on: on:
workflow_dispatch: workflow_dispatch:
inputs: {} inputs: {}
schedule: # schedule:
- cron: "0 0 * * 5" # - cron: '0 0 * * *'
jobs: jobs:
crowdin-pull: crowdin-sync:
name: Pull name: Autosync
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
env: env:
_CROWDIN_PROJECT_ID: "308189" _CROWDIN_PROJECT_ID: "308189"
@@ -30,7 +30,7 @@ jobs:
secrets: "crowdin-api-token" secrets: "crowdin-api-token"
- name: Download translations - name: Download translations
uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea # v1.3.2 uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }} CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }}

View File

@@ -9,8 +9,8 @@ on:
required: false required: false
env: env:
_QA_CLUSTER_RESOURCE_GROUP: "bw-env-qa" _QA_CLUSTER_RESOURCE_GROUP: "bitwarden-devops"
_QA_CLUSTER_NAME: "bw-aks-qa" _QA_CLUSTER_NAME: "dev-aks"
_QA_K8S_NAMESPACE: "bw-qa" _QA_K8S_NAMESPACE: "bw-qa"
_QA_K8S_APP_NAME: "bw-web" _QA_K8S_APP_NAME: "bw-web"
@@ -23,7 +23,8 @@ jobs:
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
- name: Setup - name: Setup
run: export PATH=$PATH:~/work/web/web run:
export PATH=$PATH:~/work/web/web
- name: Login to Azure - name: Login to Azure
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
@@ -35,16 +36,16 @@ jobs:
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403 uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
with: with:
keyvault: "bitwarden-qa-kv" keyvault: "bitwarden-qa-kv"
secrets: "qa-aks-kubectl-credentials" secrets: "dev-aks-kubectl-credentials"
- name: Login with qa-aks-kubectl-credentials SP - name: Login to dev-aks-kubectl SP
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
with: with:
creds: ${{ env.qa-aks-kubectl-credentials }} creds: ${{ env.dev-aks-kubectl-credentials }}
- name: Setup AKS access - name: Setup AKS access
#env: env:
# USER_ID: ${{ env.qa-kubectl-managed-identity-clientId }} USER_ID: ${{ env.qa-kubectl-managed-identity-clientId }}
run: | run: |
echo "---az install---" echo "---az install---"
az aks install-cli --install-location ./kubectl --kubelogin-install-location ./kubelogin az aks install-cli --install-location ./kubectl --kubelogin-install-location ./kubelogin
@@ -54,7 +55,7 @@ jobs:
- name: Get image tag - name: Get image tag
id: image_tag id: image_tag
run: | run: |
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") IMAGE_TAG=$(echo "$GITHUB_REF" | awk '{split($0, a, "/"); print a[3];}')
TAG_EXTENSION=${{ github.event.inputs.image_extension }} TAG_EXTENSION=${{ github.event.inputs.image_extension }}
if [[ $TAG_EXTENSION ]]; then if [[ $TAG_EXTENSION ]]; then

View File

@@ -3,15 +3,7 @@ name: Release
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs: {}
release_type:
description: 'Release Options'
required: true
default: 'Initial Release'
type: choice
options:
- Initial Release
- Redeploy
jobs: jobs:
setup: setup:
@@ -20,13 +12,12 @@ jobs:
outputs: outputs:
release_version: ${{ steps.version.outputs.package }} release_version: ${{ steps.version.outputs.package }}
tag_version: ${{ steps.version.outputs.tag }} tag_version: ${{ steps.version.outputs.tag }}
branch-name: ${{ steps.branch.outputs.branch-name }}
steps: steps:
- name: Branch check - name: Branch check
run: | run: |
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix" ]]; then if [[ "$GITHUB_REF" != "refs/heads/release" ]]; then
echo "===================================" echo "==================================="
echo "[!] Can only release from the 'rc' or 'hotfix' branches" echo "[!] Can only release from the 'release' branch"
echo "===================================" echo "==================================="
exit 1 exit 1
fi fi
@@ -42,8 +33,7 @@ jobs:
curl -sL https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r ".tag_name" curl -sL https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r ".tag_name"
) )
if [ "v$version" == "$previous_release_tag_version" ] && \ if [ "v$version" == "$previous_release_tag_version" ]; then
[ "${{ github.event.inputs.release_type }}" == "Initial Release" ]; then
echo "[!] Already released v$version. Please bump version to continue" echo "[!] Already released v$version. Please bump version to continue"
exit 1 exit 1
fi fi
@@ -51,18 +41,12 @@ jobs:
echo "::set-output name=package::$version" echo "::set-output name=package::$version"
echo "::set-output name=tag::v$version" echo "::set-output name=tag::v$version"
- name: Get branch name
id: branch
run: |
BRANCH_NAME=$(basename ${{ github.ref }})
echo "::set-output name=branch-name::$BRANCH_NAME"
self-host: self-host:
name: Release self-host docker name: Release self-host docker
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: setup needs: setup
env: env:
_BRANCH_NAME: ${{ needs.setup.outputs.branch-name }}
_RELEASE_VERSION: ${{ needs.setup.outputs.release_version }} _RELEASE_VERSION: ${{ needs.setup.outputs.release_version }}
steps: steps:
- name: Print environment - name: Print environment
@@ -82,28 +66,27 @@ jobs:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Pull latest selfhost image - name: Pull latest selfhost Release image
run: docker pull bitwarden/web:$_BRANCH_NAME run: docker pull bitwarden/web:latest
- name: Tag version and latest - name: Tag version
run: | run: |
docker tag bitwarden/web:$_BRANCH_NAME bitwarden/web:$_RELEASE_VERSION docker tag bitwarden/web:latest bitwarden/web:$_RELEASE_VERSION
docker tag bitwarden/web:$_BRANCH_NAME bitwarden/web:latest
- name: List Docker images - name: List Docker images
run: docker images run: docker images
- name: Push version and latest image - name: Push images
run: |
docker push bitwarden/web:$_RELEASE_VERSION
env: env:
DOCKER_CONTENT_TRUST: 1 DOCKER_CONTENT_TRUST: 1
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }} DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
run: |
docker push bitwarden/web:$_RELEASE_VERSION
docker push bitwarden/web:latest
- name: Log out of Docker - name: Log out of Docker
run: docker logout run: docker logout
ghpages-deploy: ghpages-deploy:
name: Deploy Web Vault name: Deploy Web Vault
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -126,6 +109,8 @@ jobs:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
with:
ref: release
- name: Setup git config - name: Setup git config
run: | run: |
@@ -139,7 +124,7 @@ jobs:
with: with:
workflow: build.yml workflow: build.yml
workflow_conclusion: success workflow_conclusion: success
branch: ${{ needs.setup.outputs.branch-name }} branch: release
artifacts: web-*-cloud-COMMERCIAL.zip artifacts: web-*-cloud-COMMERCIAL.zip
# This should result in a build directory in the current working directory # This should result in a build directory in the current working directory
@@ -166,6 +151,7 @@ jobs:
--base gh-pages \ --base gh-pages \
--head "$PR_BRANCH" --head "$PR_BRANCH"
release: release:
name: Create GitHub Release name: Create GitHub Release
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -179,7 +165,7 @@ jobs:
with: with:
workflow: build.yml workflow: build.yml
workflow_conclusion: success workflow_conclusion: success
branch: ${{ needs.setup.outputs.branch-name }} branch: release
artifacts: "web-*-selfhosted-COMMERCIAL.zip, artifacts: "web-*-selfhosted-COMMERCIAL.zip,
web-*-selfhosted-open-source.zip" web-*-selfhosted-open-source.zip"

View File

@@ -1,71 +0,0 @@
---
name: Version Bump
on:
workflow_dispatch:
inputs:
version_number:
description: "New Version"
required: true
jobs:
bump_props_version:
name: "Create version_bump_${{ github.event.inputs.version_number }} branch"
runs-on: ubuntu-20.04
steps:
- name: Checkout Branch
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Create Version Branch
run: |
git switch -c version_bump_${{ github.event.inputs.version_number }}
git push -u origin version_bump_${{ github.event.inputs.version_number }}
- name: Checkout Version Branch
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
ref: version_bump_${{ github.event.inputs.version_number }}
- name: Bump Version - package.json
uses: bitwarden/gh-actions/version-bump@03ad9a873c39cdc95dd8d77dbbda67f84db43945
with:
version: ${{ github.event.inputs.version_number }}
file_path: "./package.json"
- name: Bump Version - package-lock.json
uses: bitwarden/gh-actions/version-bump@03ad9a873c39cdc95dd8d77dbbda67f84db43945
with:
version: ${{ github.event.inputs.version_number }}
file_path: "./package-lock.json"
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Bumped version to ${{ github.event.inputs.version_number }}" -a
- name: Push changes
run: git push -u origin version_bump_${{ github.event.inputs.version_number }}
- name: Create Version PR
env:
PR_BRANCH: "version_bump_${{ github.event.inputs.version_number }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
BASE_BRANCH: master
TITLE: "Bump version to ${{ github.event.inputs.version_number }}"
run: |
gh pr create --title "$TITLE" \
--base "$BASE" \
--head "$PR_BRANCH" \
--label "version update" \
--label "automated pr" \
--body "
## Type of change
- [ ] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [X] Other
## Objective
Automated version bump to ${{ github.event.inputs.version_number }}"

View File

@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

View File

@@ -1,12 +0,0 @@
# Build directories
build
dist
jslib
# External libraries / auto synced locales
src/locales
src/404/*.min.css
# Github Workflows
.github/workflows

View File

@@ -1,3 +0,0 @@
{
"printWidth": 100
}

View File

@@ -6,12 +6,17 @@ Please visit our [Community Forums](https://community.bitwarden.com/) for genera
Here is how you can get involved: Here is how you can get involved:
- **Request a new feature:** Go to the [Feature Requests category](https://community.bitwarden.com/c/feature-requests/) of the Community Forums. Please search existing feature requests before making a new one * **Request a new feature:** Go to the [Feature Requests category](https://community.bitwarden.com/c/feature-requests/) of the Community Forums. Please search existing feature requests before making a new one
- **Write code for a new feature:** Make a new post in the [Github Contributions category](https://community.bitwarden.com/c/github-contributions/) of the Community Forums. Include a description of your proposed contribution, screeshots, and links to any relevant feature requests. This helps get feedback from the community and Bitwarden team members before you start writing code
- **Report a bug or submit a bugfix:** Use Github issues and pull requests * **Write code for a new feature:** Make a new post in the [Github Contributions category](https://community.bitwarden.com/c/github-contributions/) of the Community Forums. Include a description of your proposed contribution, screeshots, and links to any relevant feature requests. This helps get feedback from the community and Bitwarden team members before you start writing code
- **Write documentation:** Submit a pull request to the [Bitwarden help repository](https://github.com/bitwarden/help)
- **Help other users:** Go to the [User-to-User Support category](https://community.bitwarden.com/c/support/) on the Community Forums * **Report a bug or submit a bugfix:** Use Github issues and pull requests
- **Translate:** See the localization (l10n) section below
* **Write documentation:** Submit a pull request to the [Bitwarden help repository](https://github.com/bitwarden/help)
* **Help other users:** Go to the [User-to-User Support category](https://community.bitwarden.com/c/support/) on the Community Forums
* **Translate:** See the localization (l10n) section below
## Contributor Agreement ## Contributor Agreement
@@ -19,9 +24,9 @@ Please sign the [Contributor Agreement](https://cla-assistant.io/bitwarden/web)
## Pull Request Guidelines ## Pull Request Guidelines
- use `npm run lint` and fix any linting suggestions before submitting a pull request * use `npm run lint` and fix any linting suggestions before submitting a pull request
- commit any pull requests against the `master` branch * commit any pull requests against the `master` branch
- include a link to your Community Forums post * include a link to your Community Forums post
# Localization (l10n) # Localization (l10n)

View File

@@ -1,4 +1,4 @@
FROM nginx:stable FROM bitwarden/server
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"
@@ -8,29 +8,13 @@ RUN apt-get update \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY docker/nginx.conf /etc/nginx ENV ASPNETCORE_URLS http://+:5000
COPY docker/nginx-web.conf /etc/nginx
COPY docker/mime.types /etc/nginx
COPY docker/security-headers.conf /etc/nginx
WORKDIR /app WORKDIR /app
EXPOSE 5000
COPY ./build . COPY ./build .
COPY docker/entrypoint.sh / COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
RUN bash /entrypoint.sh HEALTHCHECK CMD curl -f http://localhost:5000 || exit 1
RUN chown -R bitwarden:bitwarden /app && chmod -R 755 /app && \
chown -R bitwarden:bitwarden /var/cache/nginx && \
chown -R bitwarden:bitwarden /var/log/nginx && \
chown -R bitwarden:bitwarden /etc/nginx/conf.d
RUN touch /var/run/nginx.pid && \
chown -R bitwarden:bitwarden /var/run/nginx.pid
USER bitwarden ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8080
HEALTHCHECK CMD curl -f http://localhost:8080 || exit 1
#ENTRYPOINT ["/entrypoint.sh"]
#CMD ["tail", "-f", "/dev/null"]
CMD nginx -g 'daemon off;'

View File

@@ -23,8 +23,8 @@
### Requirements ### Requirements
- [Node.js](https://nodejs.org) v16.13.1 or greater - [Node.js](https://nodejs.org) v14.17 or greater
- NPM v8 - NPM v7
### Run the app ### Run the app
@@ -41,21 +41,21 @@ If you want to point the development web vault to the production APIs, you can r
``` ```
npm install npm install
ENV=cloud npm run build:oss:watch ENV=production npm run build:oss:watch
``` ```
You can also manually adjusting your API endpoint settings by adding `config/local.json` overriding any of the following values: You can also manually adjusting your API endpoint settings by adding `config/local.json` overriding any of the following values:
```json ```json
{ {
"dev": {
"proxyApi": "http://your-api-url", "proxyApi": "http://your-api-url",
"proxyIdentity": "http://your-identity-url", "proxyIdentity": "http://your-identity-url",
"proxyEvents": "http://your-events-url", "proxyEvents": "http://your-events-url",
"proxyNotifications": "http://your-notifications-url", "proxyNotifications": "http://your-notifications-url",
"allowedHosts": ["hostnames-to-allow-in-webpack"] "allowedHosts": ["hostnames-to-allow-in-webpack"],
}, "urls": {
"urls": {}
}
} }
``` ```
@@ -66,23 +66,3 @@ Where the `urls` object is defined by the [Urls type in jslib](https://github.co
Code contributions are welcome! Please commit any pull requests against the `master` branch. Learn more about how to contribute by reading the [`CONTRIBUTING.md`](CONTRIBUTING.md) file. Code contributions are welcome! Please commit any pull requests against the `master` branch. Learn more about how to contribute by reading the [`CONTRIBUTING.md`](CONTRIBUTING.md) file.
Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the [`SECURITY.md`](SECURITY.md) file. Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the [`SECURITY.md`](SECURITY.md) file.
## Prettier
We recently migrated to using Prettier as code formatter. All previous branches will need to updated to avoid large merge conflicts using the following steps:
1. Check out your local Branch
2. Run `git merge 2b0a9d995e0147601ca8ae4778434a19354a60c2`
3. Resolve any merge conflicts, commit.
4. Run `npm run prettier`
5. Commit
6. Run `git merge -Xours 56477eb39cfd8a73c9920577d24d75fed36e2cf5`
7. Push
### Git blame
We also recommend that you configure git to ignore the prettier revision using:
```bash
git config blame.ignoreRevsFile .git-blame-ignore-revs
```

View File

@@ -1,10 +1,10 @@
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from "@angular/router"; import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [ const routes: Routes = [
{ {
path: "providers", path: 'providers',
loadChildren: async () => (await import("./providers/providers.module")).ProvidersModule, loadChildren: async () => (await import('./providers/providers.module')).ProvidersModule,
}, },
]; ];
@@ -12,4 +12,4 @@ const routes: Routes = [
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule], exports: [RouterModule],
}) })
export class AppRoutingModule {} export class AppRoutingModule { }

View File

@@ -1,14 +1,15 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { AppComponent as BaseAppComponent } from "src/app/app.component"; import { AppComponent as BaseAppComponent } from 'src/app/app.component';
import { DisablePersonalVaultExportPolicy } from "./policies/disable-personal-vault-export.component"; import { DisablePersonalVaultExportPolicy } from './policies/disable-personal-vault-export.component';
import { MaximumVaultTimeoutPolicy } from "./policies/maximum-vault-timeout.component"; import { MaximumVaultTimeoutPolicy } from './policies/maximum-vault-timeout.component';
@Component({ @Component({
selector: "app-root", selector: 'app-root',
templateUrl: "../../../src/app/app.component.html", templateUrl: '../../../src/app/app.component.html',
}) })
export class AppComponent extends BaseAppComponent { export class AppComponent extends BaseAppComponent {
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
@@ -17,4 +18,5 @@ export class AppComponent extends BaseAppComponent {
new DisablePersonalVaultExportPolicy(), new DisablePersonalVaultExportPolicy(),
]); ]);
} }
} }

View File

@@ -1,22 +1,22 @@
import { DragDropModule } from "@angular/cdk/drag-drop"; import { ToasterModule } from 'angular2-toaster';
import { NgModule } from "@angular/core"; import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { RouterModule } from "@angular/router";
import { InfiniteScrollModule } from "ngx-infinite-scroll";
import { BitwardenToastModule } from "jslib-angular/components/toastr.component"; import { DragDropModule } from '@angular/cdk/drag-drop';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from "./app-routing.module"; import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from "./app.component"; import { AppComponent } from './app.component';
import { OrganizationsModule } from "./organizations/organizations.module"; import { OrganizationsModule } from './organizations/organizations.module';
import { DisablePersonalVaultExportPolicyComponent } from "./policies/disable-personal-vault-export.component"; import { DisablePersonalVaultExportPolicyComponent } from './policies/disable-personal-vault-export.component';
import { MaximumVaultTimeoutPolicyComponent } from "./policies/maximum-vault-timeout.component"; import { MaximumVaultTimeoutPolicyComponent } from './policies/maximum-vault-timeout.component';
import { OssRoutingModule } from "src/app/oss-routing.module"; import { OssRoutingModule } from 'src/app/oss-routing.module';
import { OssModule } from "src/app/oss.module"; import { OssModule } from 'src/app/oss.module';
import { ServicesModule } from "src/app/services/services.module"; import { ServicesModule } from 'src/app/services/services.module';
import { WildcardRoutingModule } from "src/app/wildcard-routing.module"; import { WildcardRoutingModule } from 'src/app/wildcard-routing.module';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -25,11 +25,7 @@ import { WildcardRoutingModule } from "src/app/wildcard-routing.module";
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
ServicesModule, ServicesModule,
BitwardenToastModule.forRoot({ ToasterModule.forRoot(),
maxOpened: 5,
autoDismiss: true,
closeButton: true,
}),
InfiniteScrollModule, InfiniteScrollModule,
DragDropModule, DragDropModule,
AppRoutingModule, AppRoutingModule,
@@ -45,4 +41,4 @@ import { WildcardRoutingModule } from "src/app/wildcard-routing.module";
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })
export class AppModule {} export class AppModule { }

View File

@@ -1,16 +1,16 @@
import { enableProdMode } from "@angular/core"; import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import "bootstrap"; import 'bootstrap';
import "jquery"; import 'jquery';
import "popper.js"; import 'popper.js';
// tslint:disable-next-line // tslint:disable-next-line
require("src/scss/styles.scss"); require('src/scss/styles.scss');
import { AppModule } from "./app.module"; import { AppModule } from './app.module';
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === 'production') {
enableProdMode(); enableProdMode();
} }

View File

@@ -1,251 +1,114 @@
<div class="page-header d-flex"> <div class="page-header d-flex">
<h1>{{ "singleSignOn" | i18n }}</h1> <h1>{{'singleSignOn' | i18n}}</h1>
</div> </div>
<ng-container *ngIf="loading"> <ng-container *ngIf="loading">
<i <i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</ng-container> </ng-container>
<form <form #form (ngSubmit)="submit()" [formGroup]="data" [appApiAction]="formPromise" *ngIf="!loading">
#form
(ngSubmit)="submit()"
[formGroup]="data"
[appApiAction]="formPromise"
*ngIf="!loading"
ngNativeValidate
>
<p>
{{ "ssoPolicyHelpStart" | i18n }}
<a routerLink="../policies">{{ "ssoPolicyHelpLink" | i18n }}</a>
{{ "ssoPolicyHelpEnd" | i18n }}
<br />
{{ "ssoPolicyHelpKeyConnector" | i18n }}
</p>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="enabled" [formControl]="enabled" name="Enabled">
class="form-check-input" <label class="form-check-label" for="enabled">{{'enabled' | i18n}}</label>
type="checkbox"
id="enabled"
[formControl]="enabled"
name="Enabled"
/>
<label class="form-check-label" for="enabled">{{ "allowSso" | i18n }}</label>
</div> </div>
<small class="form-text text-muted">{{ "allowSsoDesc" | i18n }}</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ "memberDecryptionOption" | i18n }}</label> <label for="type">{{'type' | i18n}}</label>
<div class="form-check form-check-block">
<input
class="form-check-input"
type="radio"
id="memberDecryptionPass"
[value]="false"
formControlName="keyConnectorEnabled"
/>
<label class="form-check-label" for="memberDecryptionPass">
{{ "masterPass" | i18n }}
<small>{{ "memberDecryptionPassDesc" | i18n }}</small>
</label>
</div>
<div class="form-check mt-2 form-check-block">
<input
class="form-check-input"
type="radio"
id="memberDecryptionKey"
[value]="true"
formControlName="keyConnectorEnabled"
[attr.disabled]="!organization.useKeyConnector || null"
/>
<label class="form-check-label" for="memberDecryptionKey">
{{ "keyConnector" | i18n }}
<a
target="_blank"
rel="noopener"
appA11yTitle="{{ 'learnMore' | i18n }}"
href="https://bitwarden.com/help/article/about-key-connector/"
>
<i class="bwi bwi-question-circle" aria-hidden="true"></i>
</a>
<small>{{ "memberDecryptionKeyConnectorDesc" | i18n }}</small>
</label>
</div>
</div>
<ng-container *ngIf="data.value.keyConnectorEnabled">
<app-callout type="warning" [useAlertRole]="true">
{{ "keyConnectorWarning" | i18n }}
</app-callout>
<div class="form-group">
<label for="keyConnectorUrl">{{ "keyConnectorUrl" | i18n }}</label>
<div class="input-group">
<input
class="form-control"
formControlName="keyConnectorUrl"
id="keyConnectorUrl"
required
/>
<div class="input-group-append">
<button
type="button"
class="btn btn-outline-secondary"
(click)="validateKeyConnectorUrl()"
[disabled]="!enableTestKeyConnector"
>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
*ngIf="keyConnectorUrl.pending"
></i>
<span *ngIf="!keyConnectorUrl.pending">
{{ "keyConnectorTest" | i18n }}
</span>
</button>
</div>
</div>
<ng-container *ngIf="keyConnectorUrl.pristine && !keyConnectorUrl.pending">
<div class="text-danger" *ngIf="keyConnectorUrl.hasError('invalidUrl')" role="alert">
<i class="bwi bwi-exclamation-circle" aria-hidden="true"></i>
{{ "keyConnectorTestFail" | i18n }}
</div>
<div class="text-success" *ngIf="!keyConnectorUrl.hasError('invalidUrl')" role="alert">
<i class="bwi bwi-check-circle" aria-hidden="true"></i>
{{ "keyConnectorTestSuccess" | i18n }}
</div>
</ng-container>
</div>
</ng-container>
<div class="form-group">
<label for="type">{{ "type" | i18n }}</label>
<select class="form-control" id="type" formControlName="configType"> <select class="form-control" id="type" formControlName="configType">
<option [ngValue]="0" disabled>{{ "selectType" | i18n }}</option> <option value="0" disabled>{{'selectType' | i18n}}</option>
<option [ngValue]="1">OpenID Connect</option> <option value="1">OpenID Connect</option>
<option [ngValue]="2">SAML 2.0</option> <option value="2">SAML 2.0</option>
</select> </select>
</div> </div>
<!-- OIDC --> <!-- OIDC -->
<div *ngIf="data.value.configType == 1"> <div *ngIf="data.value.configType == 1">
<div class="config-section"> <div class="config-section">
<h2>{{ "openIdConnectConfig" | i18n }}</h2> <h2>{{'openIdConnectConfig' | i18n}}</h2>
<div class="form-group"> <div class="form-group">
<label>{{ "callbackPath" | i18n }}</label> <label>{{'callbackPath' | i18n}}</label>
<div class="input-group"> <div class="input-group">
<input class="form-control" readonly [value]="callbackPath" /> <input class="form-control" readonly [value]="callbackPath">
<div class="input-group-append"> <div class="input-group-append">
<button <button type="button" class="btn btn-outline-secondary"
type="button" appA11yTitle="{{'copyValue' | i18n}}"
class="btn btn-outline-secondary" (click)="copy(callbackPath)">
appA11yTitle="{{ 'copyValue' | i18n }}" <i class="fa fa-lg fa-clone" aria-hidden="true"></i>
(click)="copy(callbackPath)"
>
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ "signedOutCallbackPath" | i18n }}</label> <label>{{'signedOutCallbackPath' | i18n}}</label>
<div class="input-group"> <div class="input-group">
<input class="form-control" readonly [value]="signedOutCallbackPath" /> <input class="form-control" readonly [value]="signedOutCallbackPath">
<div class="input-group-append"> <div class="input-group-append">
<button <button type="button" class="btn btn-outline-secondary"
type="button" appA11yTitle="{{'copyValue' | i18n}}"
class="btn btn-outline-secondary" (click)="copy(signedOutCallbackPath)">
appA11yTitle="{{ 'copyValue' | i18n }}" <i class="fa fa-lg fa-clone" aria-hidden="true"></i>
(click)="copy(signedOutCallbackPath)"
>
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="authority">{{ "authority" | i18n }}</label> <label>{{'authority' | i18n}}</label>
<input class="form-control" formControlName="authority" id="authority" /> <input class="form-control" formControlName="authority">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="clientId">{{ "clientId" | i18n }}</label> <label>{{'clientId' | i18n}}</label>
<input class="form-control" formControlName="clientId" id="clientId" /> <input class="form-control" formControlName="clientId">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="clientSecret">{{ "clientSecret" | i18n }}</label> <label>{{'clientSecret' | i18n}}</label>
<input class="form-control" formControlName="clientSecret" id="clientSecret" /> <input class="form-control" formControlName="clientSecret">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="metadataAddress">{{ "metadataAddress" | i18n }}</label> <label>{{'metadataAddress' | i18n}}</label>
<input class="form-control" formControlName="metadataAddress" id="metadataAddress" /> <input class="form-control" formControlName="metadataAddress">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="redirectBehavior">{{ "oidcRedirectBehavior" | i18n }}</label> <label>{{'oidcRedirectBehavior' | i18n}}</label>
<select class="form-control" formControlName="redirectBehavior" id="redirectBehavior"> <select class="form-control" formControlName="redirectBehavior">
<option [ngValue]="0">Redirect GET</option> <option value="0">Redirect GET</option>
<option [ngValue]="1">Form POST</option> <option value="1">Form POST</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="getClaimsFromUserInfoEndpoint"
class="form-check-input" formControlName="getClaimsFromUserInfoEndpoint">
type="checkbox"
id="getClaimsFromUserInfoEndpoint"
formControlName="getClaimsFromUserInfoEndpoint"
/>
<label class="form-check-label" for="getClaimsFromUserInfoEndpoint"> <label class="form-check-label" for="getClaimsFromUserInfoEndpoint">
{{ "getClaimsFromUserInfoEndpoint" | i18n }} {{'getClaimsFromUserInfoEndpoint' | i18n}}
</label> </label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="additionalScopes">{{ "additionalScopes" | i18n }}</label> <label>{{'additionalScopes' | i18n}}</label>
<input class="form-control" formControlName="additionalScopes" id="additionalScopes" /> <input class="form-control" formControlName="additionalScopes">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="additionalUserIdClaimTypes">{{ "additionalUserIdClaimTypes" | i18n }}</label> <label>{{'additionalUserIdClaimTypes' | i18n}}</label>
<input <input class="form-control" formControlName="additionalUserIdClaimTypes">
class="form-control"
formControlName="additionalUserIdClaimTypes"
id="additionalUserIdClaimTypes"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="additionalEmailClaimTypes">{{ "additionalEmailClaimTypes" | i18n }}</label> <label>{{'additionalEmailClaimTypes' | i18n}}</label>
<input <input class="form-control" formControlName="additionalEmailClaimTypes">
class="form-control"
formControlName="additionalEmailClaimTypes"
id="additionalEmailClaimTypes"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="additionalNameClaimTypes">{{ "additionalNameClaimTypes" | i18n }}</label> <label>{{'additionalNameClaimTypes' | i18n}}</label>
<input <input class="form-control" formControlName="additionalNameClaimTypes">
class="form-control"
formControlName="additionalNameClaimTypes"
id="additionalNameClaimTypes"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="acrValues">{{ "acrValues" | i18n }}</label> <label>{{'acrValues' | i18n}}</label>
<input class="form-control" formControlName="acrValues" id="acrValues" /> <input class="form-control" formControlName="acrValues">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="expectedReturnAcrValue">{{ "expectedReturnAcrValue" | i18n }}</label> <label>{{'expectedReturnAcrValue' | i18n}}</label>
<input <input class="form-control" formControlName="expectedReturnAcrValue">
class="form-control"
formControlName="expectedReturnAcrValue"
id="expectedReturnAcrValue"
/>
</div> </div>
</div> </div>
</div> </div>
@@ -253,66 +116,54 @@
<div *ngIf="data.value.configType == 2"> <div *ngIf="data.value.configType == 2">
<!-- SAML2 SP --> <!-- SAML2 SP -->
<div class="config-section"> <div class="config-section">
<h2>{{ "samlSpConfig" | i18n }}</h2> <h2>{{'samlSpConfig' | i18n}}</h2>
<div class="form-group"> <div class="form-group">
<label>{{ "spEntityId" | i18n }}</label> <label>{{'spEntityId' | i18n}}</label>
<div class="input-group"> <div class="input-group">
<input class="form-control" readonly [value]="spEntityId" /> <input class="form-control" readonly [value]="spEntityId" >
<div class="input-group-append"> <div class="input-group-append">
<button <button type="button" class="btn btn-outline-secondary"
type="button" appA11yTitle="{{'copyValue' | i18n}}"
class="btn btn-outline-secondary" (click)="copy(spEntityId)">
appA11yTitle="{{ 'copyValue' | i18n }}" <i class="fa fa-lg fa-clone" aria-hidden="true"></i>
(click)="copy(spEntityId)"
>
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ "spMetadataUrl" | i18n }}</label> <label>{{'spMetadataUrl' | i18n}}</label>
<div class="input-group"> <div class="input-group">
<input class="form-control" readonly [value]="spMetadataUrl" /> <input class="form-control" readonly [value]="spMetadataUrl">
<div class="input-group-append"> <div class="input-group-append">
<button <button type="button" class="btn btn-outline-secondary"
type="button" appA11yTitle="{{'launch' | i18n}}"
class="btn btn-outline-secondary" (click)="launchUri(spMetadataUrl)">
appA11yTitle="{{ 'launch' | i18n }}" <i class="fa fa-lg fa-external-link" aria-hidden="true"></i>
(click)="launchUri(spMetadataUrl)"
>
<i class="bwi bwi-lg bwi-external-link" aria-hidden="true"></i>
</button> </button>
<button <button type="button" class="btn btn-outline-secondary"
type="button" appA11yTitle="{{'copyValue' | i18n}}"
class="btn btn-outline-secondary" (click)="copy(spMetadataUrl)">
appA11yTitle="{{ 'copyValue' | i18n }}" <i class="fa fa-lg fa-clone" aria-hidden="true"></i>
(click)="copy(spMetadataUrl)"
>
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ "spAcsUrl" | i18n }}</label> <label>{{'spAcsUrl' | i18n}}</label>
<div class="input-group"> <div class="input-group">
<input class="form-control" readonly [value]="spAcsUrl" /> <input class="form-control" readonly [value]="spAcsUrl">
<div class="input-group-append"> <div class="input-group-append">
<button <button type="button" class="btn btn-outline-secondary"
type="button" appA11yTitle="{{'copyValue' | i18n}}"
class="btn btn-outline-secondary" (click)="copy(spAcsUrl)">
appA11yTitle="{{ 'copyValue' | i18n }}" <i class="fa fa-lg fa-clone" aria-hidden="true"></i>
(click)="copy(spAcsUrl)"
>
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="spNameIdFormat">{{ "spNameIdFormat" | i18n }}</label> <label>{{'spNameIdFormat' | i18n}}</label>
<select class="form-control" formControlName="spNameIdFormat" id="spNameIdFormat"> <select class="form-control" formControlName="spNameIdFormat">
<option value="0">Not Configured</option> <option value="0">Not Configured</option>
<option value="1">Unspecified</option> <option value="1">Unspecified</option>
<option value="2">Email Address</option> <option value="2">Email Address</option>
@@ -325,160 +176,101 @@
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="spOutboundSigningAlgorithm">{{ "spOutboundSigningAlgorithm" | i18n }}</label> <label>{{'spOutboundSigningAlgorithm' | i18n}}</label>
<select <select class="form-control" formControlName="spOutboundSigningAlgorithm">
class="form-control" <option *ngFor="let o of samlSigningAlgorithms" [ngValue]="o">{{o}}</option>
formControlName="spOutboundSigningAlgorithm"
id="spOutboundSigningAlgorithm"
>
<option *ngFor="let o of samlSigningAlgorithms" [ngValue]="o">{{ o }}</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="spSigningBehavior">{{ "spSigningBehavior" | i18n }}</label> <label>{{'spSigningBehavior' | i18n}}</label>
<select class="form-control" formControlName="spSigningBehavior" id="spSigningBehavior"> <select class="form-control" formControlName="spSigningBehavior">
<option value="0">If IdP Wants Authn Requests Signed</option> <option value="0">If IdP Wants Authn Requests Signed</option>
<option value="1">Always</option> <option value="1">Always</option>
<option value="3">Never</option> <option value="3">Never</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="spMinIncomingSigningAlgorithm">{{ <label>{{'spMinIncomingSigningAlgorithm' | i18n}}</label>
"spMinIncomingSigningAlgorithm" | i18n <select class="form-control" formControlName="spMinIncomingSigningAlgorithm">
}}</label> <option *ngFor="let o of samlSigningAlgorithms" [ngValue]="o">{{o}}</option>
<select
class="form-control"
formControlName="spMinIncomingSigningAlgorithm"
id="spMinIncomingSigningAlgorithm"
>
<option *ngFor="let o of samlSigningAlgorithms" [ngValue]="o">{{ o }}</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="spWantAssertionsSigned" formControlName="spWantAssertionsSigned">
class="form-check-input" <label class="form-check-label" for="spWantAssertionsSigned">{{'spWantAssertionsSigned' | i18n}}</label>
type="checkbox"
id="spWantAssertionsSigned"
formControlName="spWantAssertionsSigned"
/>
<label class="form-check-label" for="spWantAssertionsSigned">
{{ "spWantAssertionsSigned" | i18n }}
</label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="spValidateCertificates" formControlName="spValidateCertificates">
class="form-check-input" <label class="form-check-label" for="spValidateCertificates">{{'spValidateCertificates' | i18n}}</label>
type="checkbox"
id="spValidateCertificates"
formControlName="spValidateCertificates"
/>
<label class="form-check-label" for="spValidateCertificates">
{{ "spValidateCertificates" | i18n }}
</label>
</div> </div>
</div> </div>
</div> </div>
<!-- SAML2 IDP --> <!-- SAML2 IDP -->
<div class="config-section"> <div class="config-section">
<h2>{{ "samlIdpConfig" | i18n }}</h2> <h2>{{'samlIdpConfig' | i18n}}</h2>
<div class="form-group"> <div class="form-group">
<label for="idpEntityId">{{ "idpEntityId" | i18n }}</label> <label>{{'idpEntityId' | i18n}}</label>
<input class="form-control" formControlName="idpEntityId" id="idpEntityId" /> <input class="form-control" formControlName="idpEntityId">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idpBindingType">{{ "idpBindingType" | i18n }}</label> <label>{{'idpBindingType' | i18n}}</label>
<select class="form-control" formControlName="idpBindingType" id="idpBindingType"> <select class="form-control" formControlName="idpBindingType">
<option value="1">Redirect</option> <option value="1">Redirect</option>
<option value="2">HTTP POST</option> <option value="2">HTTP POST</option>
<option value="4">Artifact</option> <option value="4">Artifact</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idpSingleSignOnServiceUrl">{{ "idpSingleSignOnServiceUrl" | i18n }}</label> <label>{{'idpSingleSignOnServiceUrl' | i18n}}</label>
<input <input class="form-control" formControlName="idpSingleSignOnServiceUrl">
class="form-control"
formControlName="idpSingleSignOnServiceUrl"
id="idpSingleSignOnServiceUrl"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idpSingleLogoutServiceUrl">{{ "idpSingleLogoutServiceUrl" | i18n }}</label> <label>{{'idpSingleLogoutServiceUrl' | i18n}}</label>
<input <input class="form-control" formControlName="idpSingleLogoutServiceUrl">
class="form-control"
formControlName="idpSingleLogoutServiceUrl"
id="idpSingleLogoutServiceUrl"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idpArtifactResolutionServiceUrl">{{ <label>{{'idpArtifactResolutionServiceUrl' | i18n}}</label>
"idpArtifactResolutionServiceUrl" | i18n <input class="form-control" formControlName="idpArtifactResolutionServiceUrl">
}}</label>
<input
class="form-control"
formControlName="idpArtifactResolutionServiceUrl"
id="idpArtifactResolutionServiceUrl"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idpX509PublicCert">{{ "idpX509PublicCert" | i18n }}</label> <label>{{'idpX509PublicCert' | i18n}}</label>
<textarea <textarea formControlName="idpX509PublicCert" class="form-control form-control-sm text-monospace" rows="6"></textarea>
formControlName="idpX509PublicCert"
class="form-control form-control-sm text-monospace"
rows="6"
id="idpX509PublicCert"
></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idpOutboundSigningAlgorithm">{{ "idpOutboundSigningAlgorithm" | i18n }}</label> <label>{{'idpOutboundSigningAlgorithm' | i18n}}</label>
<select <select class="form-control" formControlName="idpOutboundSigningAlgorithm">
class="form-control" <option *ngFor="let o of samlSigningAlgorithms" [ngValue]="o">{{o}}</option>
formControlName="idpOutboundSigningAlgorithm"
id="idpOutboundSigningAlgorithm"
>
<option *ngFor="let o of samlSigningAlgorithms" [ngValue]="o">{{ o }}</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="idpAllowUnsolicitedAuthnResponse"
class="form-check-input" formControlName="idpAllowUnsolicitedAuthnResponse">
type="checkbox"
id="idpAllowUnsolicitedAuthnResponse"
formControlName="idpAllowUnsolicitedAuthnResponse"
/>
<label class="form-check-label" for="idpAllowUnsolicitedAuthnResponse"> <label class="form-check-label" for="idpAllowUnsolicitedAuthnResponse">
{{ "idpAllowUnsolicitedAuthnResponse" | i18n }} {{'idpAllowUnsolicitedAuthnResponse' | i18n}}
</label> </label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="idpDisableOutboundLogoutRequests"
class="form-check-input" formControlName="idpDisableOutboundLogoutRequests">
type="checkbox"
id="idpDisableOutboundLogoutRequests"
formControlName="idpDisableOutboundLogoutRequests"
/>
<label class="form-check-label" for="idpDisableOutboundLogoutRequests"> <label class="form-check-label" for="idpDisableOutboundLogoutRequests">
{{ "idpDisableOutboundLogoutRequests" | i18n }} {{'idpDisableOutboundLogoutRequests' | i18n}}
</label> </label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="idpWantAuthnRequestsSigned"
class="form-check-input" formControlName="idpWantAuthnRequestsSigned">
type="checkbox"
id="idpWantAuthnRequestsSigned"
formControlName="idpWantAuthnRequestsSigned"
/>
<label class="form-check-label" for="idpWantAuthnRequestsSigned"> <label class="form-check-label" for="idpWantAuthnRequestsSigned">
{{ "idpWantAuthnRequestsSigned" | i18n }} {{'idpWantAuthnRequestsSigned' | i18n}}
</label> </label>
</div> </div>
</div> </div>
@@ -486,7 +278,7 @@
</div> </div>
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading"> <button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span>{{ "save" | i18n }}</span> <span>{{'save' | i18n}}</span>
</button> </button>
</form> </form>

View File

@@ -1,31 +1,30 @@
import { Component, OnInit } from "@angular/core"; import {
import { FormBuilder } from "@angular/forms"; Component,
import { ActivatedRoute } from "@angular/router"; OnInit,
} from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
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 { I18nService } from 'jslib-common/abstractions/i18n.service';
import { OrganizationService } from "jslib-common/abstractions/organization.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { OrganizationSsoRequest } from 'jslib-common/models/request/organization/organizationSsoRequest';
import { Organization } from "jslib-common/models/domain/organization";
import { OrganizationSsoRequest } from "jslib-common/models/request/organization/organizationSsoRequest";
@Component({ @Component({
selector: "app-org-manage-sso", selector: 'app-org-manage-sso',
templateUrl: "sso.component.html", templateUrl: 'sso.component.html',
}) })
export class SsoComponent implements OnInit { export class SsoComponent implements OnInit {
samlSigningAlgorithms = [ samlSigningAlgorithms = [
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
"http://www.w3.org/2000/09/xmldsig#rsa-sha384", 'http://www.w3.org/2000/09/xmldsig#rsa-sha384',
"http://www.w3.org/2000/09/xmldsig#rsa-sha512", 'http://www.w3.org/2000/09/xmldsig#rsa-sha512',
"http://www.w3.org/2000/09/xmldsig#rsa-sha1", 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
]; ];
loading = true; loading = true;
organizationId: string; organizationId: string;
organization: Organization;
formPromise: Promise<any>; formPromise: Promise<any>;
callbackPath: string; callbackPath: string;
@@ -34,13 +33,10 @@ export class SsoComponent implements OnInit {
spMetadataUrl: string; spMetadataUrl: string;
spAcsUrl: string; spAcsUrl: string;
enabled = this.formBuilder.control(false); enabled = this.fb.control(false);
data = this.formBuilder.group({ data = this.fb.group({
configType: [], configType: [],
keyConnectorEnabled: [],
keyConnectorUrl: [],
// OpenId // OpenId
authority: [], authority: [],
clientId: [], clientId: [],
@@ -75,24 +71,17 @@ export class SsoComponent implements OnInit {
idpWantAuthnRequestsSigned: [], idpWantAuthnRequestsSigned: [],
}); });
constructor( constructor(private fb: FormBuilder, private route: ActivatedRoute, private apiService: ApiService,
private formBuilder: FormBuilder, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService) { }
private route: ActivatedRoute,
private apiService: ApiService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private organizationService: OrganizationService
) {}
async ngOnInit() { async ngOnInit() {
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async params => {
this.organizationId = params.organizationId; this.organizationId = params.organizationId;
await this.load(); await this.load();
}); });
} }
async load() { async load() {
this.organization = await this.organizationService.get(this.organizationId);
const ssoSettings = await this.apiService.getOrganizationSso(this.organizationId); const ssoSettings = await this.apiService.getOrganizationSso(this.organizationId);
this.data.patchValue(ssoSettings.data); this.data.patchValue(ssoSettings.data);
@@ -104,8 +93,6 @@ export class SsoComponent implements OnInit {
this.spMetadataUrl = ssoSettings.urls.spMetadataUrl; this.spMetadataUrl = ssoSettings.urls.spMetadataUrl;
this.spAcsUrl = ssoSettings.urls.spAcsUrl; this.spAcsUrl = ssoSettings.urls.spAcsUrl;
this.keyConnectorUrl.markAsDirty();
this.loading = false; this.loading = false;
} }
@@ -118,66 +105,17 @@ export class SsoComponent implements OnInit {
} }
async submit() { async submit() {
this.formPromise = this.postData();
try {
const response = await this.formPromise;
this.data.patchValue(response.data);
this.enabled.setValue(response.enabled);
this.platformUtilsService.showToast("success", null, this.i18nService.t("ssoSettingsSaved"));
} catch {
// Logged by appApiAction, do nothing
}
this.formPromise = null;
}
async postData() {
if (this.data.get("keyConnectorEnabled").value) {
await this.validateKeyConnectorUrl();
if (this.keyConnectorUrl.hasError("invalidUrl")) {
throw new Error(this.i18nService.t("keyConnectorTestFail"));
}
}
const request = new OrganizationSsoRequest(); const request = new OrganizationSsoRequest();
request.enabled = this.enabled.value; request.enabled = this.enabled.value;
request.data = this.data.value; request.data = this.data.value;
return this.apiService.postOrganizationSso(this.organizationId, request); this.formPromise = this.apiService.postOrganizationSso(this.organizationId, request);
}
async validateKeyConnectorUrl() { const response = await this.formPromise;
if (this.keyConnectorUrl.pristine) { this.data.patchValue(response.data);
return; this.enabled.setValue(response.enabled);
}
this.keyConnectorUrl.markAsPending(); this.formPromise = null;
this.platformUtilsService.showToast('success', null, this.i18nService.t('ssoSettingsSaved'));
try {
await this.apiService.getKeyConnectorAlive(this.keyConnectorUrl.value);
this.keyConnectorUrl.updateValueAndValidity();
} catch {
this.keyConnectorUrl.setErrors({
invalidUrl: true,
});
}
this.keyConnectorUrl.markAsPristine();
}
get enableTestKeyConnector() {
return (
this.data.get("keyConnectorEnabled").value &&
this.keyConnectorUrl != null &&
this.keyConnectorUrl.value !== ""
);
}
get keyConnectorUrl() {
return this.data.get("keyConnectorUrl");
} }
} }

View File

@@ -1,25 +1,25 @@
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from "@angular/router"; import { RouterModule, Routes } from '@angular/router';
import { AuthGuardService } from "jslib-angular/services/auth-guard.service"; import { AuthGuardService } from 'jslib-angular/services/auth-guard.service';
import { Permissions } from "jslib-common/enums/permissions"; import { Permissions } from 'jslib-common/enums/permissions';
import { OrganizationLayoutComponent } from "src/app/layouts/organization-layout.component"; import { OrganizationLayoutComponent } from 'src/app/layouts/organization-layout.component';
import { ManageComponent } from "src/app/organizations/manage/manage.component"; import { ManageComponent } from 'src/app/organizations/manage/manage.component';
import { OrganizationGuardService } from "src/app/services/organization-guard.service"; import { OrganizationGuardService } from 'src/app/services/organization-guard.service';
import { OrganizationTypeGuardService } from "src/app/services/organization-type-guard.service"; import { OrganizationTypeGuardService } from 'src/app/services/organization-type-guard.service';
import { SsoComponent } from "./manage/sso.component"; import { SsoComponent } from './manage/sso.component';
const routes: Routes = [ const routes: Routes = [
{ {
path: "organizations/:organizationId", path: 'organizations/:organizationId',
component: OrganizationLayoutComponent, component: OrganizationLayoutComponent,
canActivate: [AuthGuardService, OrganizationGuardService], canActivate: [AuthGuardService, OrganizationGuardService],
children: [ children: [
{ {
path: "manage", path: 'manage',
component: ManageComponent, component: ManageComponent,
canActivate: [OrganizationTypeGuardService], canActivate: [OrganizationTypeGuardService],
data: { data: {
@@ -38,7 +38,7 @@ const routes: Routes = [
}, },
children: [ children: [
{ {
path: "sso", path: 'sso',
component: SsoComponent, component: SsoComponent,
}, },
], ],
@@ -51,4 +51,4 @@ const routes: Routes = [
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule], exports: [RouterModule],
}) })
export class OrganizationsRoutingModule {} export class OrganizationsRoutingModule { }

View File

@@ -1,14 +1,22 @@
import { CommonModule } from "@angular/common"; import { CommonModule } from '@angular/common';
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { OssModule } from "src/app/oss.module"; import { OssModule } from 'src/app/oss.module';
import { SsoComponent } from "./manage/sso.component"; import { SsoComponent } from './manage/sso.component';
import { OrganizationsRoutingModule } from "./organizations-routing.module"; import { OrganizationsRoutingModule } from './organizations-routing.module';
@NgModule({ @NgModule({
imports: [CommonModule, FormsModule, ReactiveFormsModule, OssModule, OrganizationsRoutingModule], imports: [
declarations: [SsoComponent], CommonModule,
FormsModule,
ReactiveFormsModule,
OssModule,
OrganizationsRoutingModule,
],
declarations: [
SsoComponent,
],
}) })
export class OrganizationsModule {} export class OrganizationsModule {}

View File

@@ -1,12 +1,6 @@
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="enabled" [formControl]="enabled" name="Enabled">
class="form-check-input" <label class="form-check-label" for="enabled">{{'enabled' | i18n}}</label>
type="checkbox"
id="enabled"
[formControl]="enabled"
name="Enabled"
/>
<label class="form-check-label" for="enabled">{{ "enabled" | i18n }}</label>
</div> </div>
</div> </div>

View File

@@ -1,26 +1,24 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from '@angular/forms';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PolicyType } from "jslib-common/enums/policyType"; import { PolicyType } from 'jslib-common/enums/policyType';
import { PolicyRequest } from "jslib-common/models/request/policyRequest"; import { PolicyRequest } from 'jslib-common/models/request/policyRequest';
import { import { BasePolicy, BasePolicyComponent } from 'src/app/organizations/policies/base-policy.component';
BasePolicy,
BasePolicyComponent,
} from "src/app/organizations/policies/base-policy.component";
export class DisablePersonalVaultExportPolicy extends BasePolicy { export class DisablePersonalVaultExportPolicy extends BasePolicy {
name = "disablePersonalVaultExport"; name = 'disablePersonalVaultExport';
description = "disablePersonalVaultExportDesc"; description = 'disablePersonalVaultExportDesc';
type = PolicyType.DisablePersonalVaultExport; type = PolicyType.DisablePersonalVaultExport;
component = DisablePersonalVaultExportPolicyComponent; component = DisablePersonalVaultExportPolicyComponent;
} }
@Component({ @Component({
selector: "policy-disable-personal-vault-export", selector: 'policy-disable-personal-vault-export',
templateUrl: "disable-personal-vault-export.component.html", templateUrl: 'disable-personal-vault-export.component.html',
}) })
export class DisablePersonalVaultExportPolicyComponent extends BasePolicyComponent {} export class DisablePersonalVaultExportPolicyComponent extends BasePolicyComponent {
}

View File

@@ -1,46 +1,26 @@
<app-callout type="tip" title="{{ 'prerequisite' | i18n }}"> <app-callout type="tip" title="{{'prerequisite' | i18n}}">
{{ "requireSsoPolicyReq" | i18n }} {{'requireSsoPolicyReq' | i18n}}
</app-callout> </app-callout>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="enabled" [formControl]="enabled" name="Enabled">
class="form-check-input" <label class="form-check-label" for="enabled">{{'enabled' | i18n}}</label>
type="checkbox"
id="enabled"
[formControl]="enabled"
name="Enabled"
/>
<label class="form-check-label" for="enabled">{{ "enabled" | i18n }}</label>
</div> </div>
</div> </div>
<div [formGroup]="data"> <div [formGroup]="data">
<div class="form-group"> <div class="form-group">
<label for="hours">{{ "maximumVaultTimeoutLabel" | i18n }}</label> <label for="hours">{{'maximumVaultTimeoutLabel' | i18n}}</label>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<input <input id="hours" class="form-control" type="number" min="0" name="hours" formControlName="hours">
id="hours" <small>{{'hours' | i18n }}</small>
class="form-control"
type="number"
min="0"
name="hours"
formControlName="hours"
/>
<small>{{ "hours" | i18n }}</small>
</div> </div>
<div class="col-6"> <div class="col-6">
<input <input id="minutes" class="form-control" type="number" min="0" max="59" name="minutes"
id="minutes" formControlName="minutes">
class="form-control" <small>{{'minutes' | i18n }}</small>
type="number"
min="0"
max="59"
name="minutes"
formControlName="minutes"
/>
<small>{{ "minutes" | i18n }}</small>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,35 +1,33 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from '@angular/forms';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PolicyType } from "jslib-common/enums/policyType"; import { PolicyType } from 'jslib-common/enums/policyType';
import { PolicyRequest } from "jslib-common/models/request/policyRequest"; import { PolicyRequest } from 'jslib-common/models/request/policyRequest';
import { import { BasePolicy, BasePolicyComponent } from 'src/app/organizations/policies/base-policy.component';
BasePolicy,
BasePolicyComponent,
} from "src/app/organizations/policies/base-policy.component";
export class MaximumVaultTimeoutPolicy extends BasePolicy { export class MaximumVaultTimeoutPolicy extends BasePolicy {
name = "maximumVaultTimeout"; name = 'maximumVaultTimeout';
description = "maximumVaultTimeoutDesc"; description = 'maximumVaultTimeoutDesc';
type = PolicyType.MaximumVaultTimeout; type = PolicyType.MaximumVaultTimeout;
component = MaximumVaultTimeoutPolicyComponent; component = MaximumVaultTimeoutPolicyComponent;
} }
@Component({ @Component({
selector: "policy-maximum-timeout", selector: 'policy-maximum-timeout',
templateUrl: "maximum-vault-timeout.component.html", templateUrl: 'maximum-vault-timeout.component.html',
}) })
export class MaximumVaultTimeoutPolicyComponent extends BasePolicyComponent { export class MaximumVaultTimeoutPolicyComponent extends BasePolicyComponent {
data = this.formBuilder.group({
data = this.fb.group({
hours: [null], hours: [null],
minutes: [null], minutes: [null],
}); });
constructor(private formBuilder: FormBuilder, private i18nService: I18nService) { constructor(private fb: FormBuilder, private i18nService: I18nService) {
super(); super();
} }
@@ -59,12 +57,12 @@ export class MaximumVaultTimeoutPolicyComponent extends BasePolicyComponent {
buildRequest(policiesEnabledMap: Map<PolicyType, boolean>): Promise<PolicyRequest> { buildRequest(policiesEnabledMap: Map<PolicyType, boolean>): Promise<PolicyRequest> {
const singleOrgEnabled = policiesEnabledMap.get(PolicyType.SingleOrg) ?? false; const singleOrgEnabled = policiesEnabledMap.get(PolicyType.SingleOrg) ?? false;
if (this.enabled.value && !singleOrgEnabled) { if (this.enabled.value && !singleOrgEnabled) {
throw new Error(this.i18nService.t("requireSsoPolicyReqError")); throw new Error(this.i18nService.t('requireSsoPolicyReqError'));
} }
const data = this.buildRequestData(); const data = this.buildRequestData();
if (data?.minutes == null || data?.minutes <= 0) { if (data?.minutes == null || data?.minutes <= 0) {
throw new Error(this.i18nService.t("invalidMaximumVaultTimeout")); throw new Error(this.i18nService.t('invalidMaximumVaultTimeout'));
} }
return super.buildRequest(policiesEnabledMap); return super.buildRequest(policiesEnabledMap);

View File

@@ -1,23 +1,18 @@
<div class="modal fade" role="dialog" aria-modal="true" aria-labelledby="addTitle"> <div class="modal fade" tabindex="-1" role="dialog" aria-modal="true" aria-labelledby="addTitle">
<div class="modal-dialog modal-dialog-scrollable" role="document"> <div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h2 class="modal-title" id="addTitle"> <h2 class="modal-title" id="addTitle">
{{ "addExistingOrganization" | i18n }} {{'addExistingOrganization' | i18n}}
</h2> </h2>
<button <button type="button" class="close" data-dismiss="modal" appA11yTitle="{{'close' | i18n}}">
type="button"
class="close"
data-dismiss="modal"
appA11yTitle="{{ 'close' | i18n }}"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="card-body text-center" *ngIf="loading"> <div class="card-body text-center" *ngIf="loading">
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
{{ "loading" | i18n }} {{'loading' | i18n}}
</div> </div>
<ng-container *ngIf="!loading"> <ng-container *ngIf="!loading">
<table class="table table-hover table-list"> <table class="table table-hover table-list">
@@ -26,16 +21,10 @@
<app-avatar [data]="o.name" size="25" [circle]="true" [fontSize]="14"></app-avatar> <app-avatar [data]="o.name" size="25" [circle]="true" [fontSize]="14"></app-avatar>
</td> </td>
<td> <td>
{{ o.name }} {{o.name}}
</td> </td>
<td> <td>
<button <button class="btn btn-outline-secondary pull-right" (click)="add(o)" [disabled]="formPromise">Add</button>
class="btn btn-outline-secondary pull-right"
(click)="add(o)"
[disabled]="formPromise"
>
Add
</button>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -1,21 +1,32 @@
import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core"; import {
Component,
EventEmitter,
Input,
OnInit,
Output
} from '@angular/core';
import { ToasterService } from 'angular2-toaster';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ValidationService } from "jslib-angular/services/validation.service"; import { ValidationService } from 'jslib-angular/services/validation.service';
import { WebProviderService } from "../services/webProvider.service"; import { ProviderService } from '../services/provider.service';
import { Organization } from "jslib-common/models/domain/organization"; import { Organization } from 'jslib-common/models/domain/organization';
import { Provider } from "jslib-common/models/domain/provider"; import { Provider } from 'jslib-common/models/domain/provider';
import { PlanType } from 'jslib-common/enums/planType';
@Component({ @Component({
selector: "provider-add-organization", selector: 'provider-add-organization',
templateUrl: "add-organization.component.html", templateUrl: 'add-organization.component.html',
}) })
export class AddOrganizationComponent implements OnInit { export class AddOrganizationComponent implements OnInit {
@Input() providerId: string; @Input() providerId: string;
@Input() organizations: Organization[]; @Input() organizations: Organization[];
@Output() onAddedOrganization = new EventEmitter(); @Output() onAddedOrganization = new EventEmitter();
@@ -24,13 +35,10 @@ export class AddOrganizationComponent implements OnInit {
formPromise: Promise<any>; formPromise: Promise<any>;
loading = true; loading = true;
constructor( constructor(private userService: UserService, private providerService: ProviderService,
private providerService: ProviderService, private toasterService: ToasterService, private i18nService: I18nService,
private webProviderService: WebProviderService, private platformUtilsService: PlatformUtilsService, private validationService: ValidationService,
private i18nService: I18nService, private apiService: ApiService) { }
private platformUtilsService: PlatformUtilsService,
private validationService: ValidationService
) {}
async ngOnInit() { async ngOnInit() {
await this.load(); await this.load();
@@ -41,7 +49,7 @@ export class AddOrganizationComponent implements OnInit {
return; return;
} }
this.provider = await this.providerService.get(this.providerId); this.provider = await this.userService.getProvider(this.providerId);
this.loading = false; this.loading = false;
} }
@@ -52,22 +60,15 @@ export class AddOrganizationComponent implements OnInit {
} }
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t("addOrganizationConfirmation", organization.name, this.provider.name), this.i18nService.t('addOrganizationConfirmation', organization.name, this.provider.name), organization.name,
organization.name, this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
this.i18nService.t("yes"),
this.i18nService.t("no"),
"warning"
);
if (!confirmed) { if (!confirmed) {
return false; return false;
} }
try { try {
this.formPromise = this.webProviderService.addOrganizationToProvider( this.formPromise = this.providerService.addOrganizationToProvider(this.providerId, organization.id);
this.providerId,
organization.id
);
await this.formPromise; await this.formPromise;
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
@@ -76,11 +77,7 @@ export class AddOrganizationComponent implements OnInit {
this.formPromise = null; this.formPromise = null;
} }
this.platformUtilsService.showToast( this.toasterService.popAsync('success', null, this.i18nService.t('organizationJoinedProvider'));
"success",
null,
this.i18nService.t("organizationJoinedProvider")
);
this.onAddedOrganization.emit(); this.onAddedOrganization.emit();
} }
} }

View File

@@ -1,82 +1,54 @@
<div class="page-header d-flex"> <div class="page-header d-flex">
<h1>{{ "clients" | i18n }}</h1> <h1>{{'clients' | i18n}}</h1>
<div class="ml-auto d-flex"> <div class="ml-auto d-flex">
<div> <div>
<label class="sr-only" for="search">{{ "search" | i18n }}</label> <label class="sr-only" for="search">{{'search' | i18n}}</label>
<input <input type="search" class="form-control form-control-sm" id="search" placeholder="{{'search' | i18n}}"
type="search" [(ngModel)]="searchText">
class="form-control form-control-sm"
id="search"
placeholder="{{ 'search' | i18n }}"
[(ngModel)]="searchText"
/>
</div> </div>
<a class="btn btn-sm btn-outline-primary ml-3" routerLink="create" *ngIf="manageOrganizations"> <a class="btn btn-sm btn-outline-primary ml-3" routerLink="create" *ngIf="manageOrganizations">
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i> <i class="fa fa-plus fa-fw" aria-hidden="true"></i>
{{ "newClientOrganization" | i18n }} {{'newClientOrganization' | i18n}}
</a> </a>
<button <button class="btn btn-sm btn-outline-primary ml-3" (click)="addExistingOrganization()"
class="btn btn-sm btn-outline-primary ml-3" *ngIf="manageOrganizations && showAddExisting">
(click)="addExistingOrganization()" <i class="fa fa-plus fa-fw" aria-hidden="true"></i>
*ngIf="manageOrganizations && showAddExisting" {{'addExistingOrganization' | i18n}}
>
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
{{ "addExistingOrganization" | i18n }}
</button> </button>
</div> </div>
</div> </div>
<ng-container *ngIf="loading"> <ng-container *ngIf="loading">
<i <i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</ng-container> </ng-container>
<ng-container <ng-container
*ngIf="!loading && (clients | search: searchText:'organizationName':'id') as searchedClients" *ngIf="!loading && (clients | search:searchText:'organizationName':'id') as searchedClients">
> <p *ngIf="!searchedClients.length">{{'noClientsInList' | i18n}}</p>
<p *ngIf="!searchedClients.length">{{ "noClientsInList" | i18n }}</p>
<ng-container *ngIf="searchedClients.length"> <ng-container *ngIf="searchedClients.length">
<table <table class="table table-hover table-list" infiniteScroll [infiniteScrollDistance]="1"
class="table table-hover table-list" [infiniteScrollDisabled]="!isPaging()" (scrolled)="loadMore()">
infiniteScroll
[infiniteScrollDistance]="1"
[infiniteScrollDisabled]="!isPaging()"
(scrolled)="loadMore()"
>
<tbody> <tbody>
<tr *ngFor="let o of searchedClients"> <tr *ngFor="let o of searchedClients">
<td width="30"> <td width="30">
<app-avatar <app-avatar [data]="o.organizationName" size="25" [circle]="true" [fontSize]="14"></app-avatar>
[data]="o.organizationName"
size="25"
[circle]="true"
[fontSize]="14"
></app-avatar>
</td> </td>
<td> <td>
<a [routerLink]="['/organizations', o.organizationId]">{{ o.organizationName }}</a> <a [routerLink]="['/organizations', o.organizationId]">{{o.organizationName}}</a>
</td> </td>
<td class="table-list-options" *ngIf="manageOrganizations"> <td class="table-list-options" *ngIf="manageOrganizations">
<div class="dropdown" appListDropdown> <div class="dropdown" appListDropdown>
<button <button class="btn btn-outline-secondary dropdown-toggle" type="button"
class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
type="button" appA11yTitle="{{'options' | i18n}}">
data-toggle="dropdown" <i class="fa fa-cog fa-lg" aria-hidden="true"></i>
aria-haspopup="true"
aria-expanded="false"
appA11yTitle="{{ 'options' | i18n }}"
>
<i class="bwi bwi-cog bwi-lg" aria-hidden="true"></i>
</button> </button>
<div class="dropdown-menu dropdown-menu-right"> <div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item text-danger" href="#" appStopClick (click)="remove(o)"> <a class="dropdown-item text-danger" href="#" appStopClick (click)="remove(o)">
<i class="bwi bwi-fw bwi-close" aria-hidden="true"></i> <i class="fa fa-fw fa-remove" aria-hidden="true"></i>
{{ "remove" | i18n }} {{'remove' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,40 +1,42 @@
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core"; import {
import { ActivatedRoute } from "@angular/router"; Component,
OnInit,
ViewChild,
ViewContainerRef
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ToasterService } from 'angular2-toaster';
import { first } from "rxjs/operators"; 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 { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ModalService } from 'jslib-angular/services/modal.service';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { ValidationService } from 'jslib-angular/services/validation.service';
import { LogService } from "jslib-common/abstractions/log.service";
import { OrganizationService } from "jslib-common/abstractions/organization.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { ProviderService } from "jslib-common/abstractions/provider.service";
import { SearchService } from "jslib-common/abstractions/search.service";
import { ModalService } from "jslib-angular/services/modal.service"; import { PlanType } from 'jslib-common/enums/planType';
import { ValidationService } from "jslib-angular/services/validation.service"; import { ProviderUserType } from 'jslib-common/enums/providerUserType';
import { PlanType } from "jslib-common/enums/planType"; import { Organization } from 'jslib-common/models/domain/organization';
import { ProviderUserType } from "jslib-common/enums/providerUserType"; import {
ProviderOrganizationOrganizationDetailsResponse
} from 'jslib-common/models/response/provider/providerOrganizationResponse';
import { Organization } from "jslib-common/models/domain/organization"; import { ProviderService } from '../services/provider.service';
import { ProviderOrganizationOrganizationDetailsResponse } from "jslib-common/models/response/provider/providerOrganizationResponse";
import { WebProviderService } from "../services/webProvider.service"; import { AddOrganizationComponent } from './add-organization.component';
import { AddOrganizationComponent } from "./add-organization.component"; const DisallowedPlanTypes = [PlanType.Free, PlanType.FamiliesAnnually2019, PlanType.FamiliesAnnually];
const DisallowedPlanTypes = [
PlanType.Free,
PlanType.FamiliesAnnually2019,
PlanType.FamiliesAnnually,
];
@Component({ @Component({
templateUrl: "clients.component.html", templateUrl: 'clients.component.html',
}) })
export class ClientsComponent implements OnInit { export class ClientsComponent implements OnInit {
@ViewChild("add", { read: ViewContainerRef, static: true }) addModalRef: ViewContainerRef;
@ViewChild('add', { read: ViewContainerRef, static: true }) addModalRef: ViewContainerRef;
providerId: any; providerId: any;
searchText: string; searchText: string;
@@ -51,28 +53,24 @@ export class ClientsComponent implements OnInit {
protected actionPromise: Promise<any>; protected actionPromise: Promise<any>;
private pagedClientsCount = 0; private pagedClientsCount = 0;
constructor( constructor(private route: ActivatedRoute, private userService: UserService,
private route: ActivatedRoute, private apiService: ApiService, private searchService: SearchService,
private providerService: ProviderService, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private apiService: ApiService, private toasterService: ToasterService, private validationService: ValidationService,
private searchService: SearchService, private providerService: ProviderService, private logService: LogService,
private platformUtilsService: PlatformUtilsService, private modalService: ModalService) { }
private i18nService: I18nService,
private validationService: ValidationService,
private webProviderService: WebProviderService,
private logService: LogService,
private modalService: ModalService,
private organizationService: OrganizationService
) {}
async ngOnInit() { async ngOnInit() {
this.route.parent.params.subscribe(async (params) => { this.route.parent.params.subscribe(async params => {
this.providerId = params.providerId; this.providerId = params.providerId;
await this.load(); await this.load();
this.route.queryParams.pipe(first()).subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
this.searchText = qParams.search; this.searchText = qParams.search;
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
}); });
}); });
} }
@@ -80,17 +78,12 @@ export class ClientsComponent implements OnInit {
async load() { async load() {
const response = await this.apiService.getProviderClients(this.providerId); const response = await this.apiService.getProviderClients(this.providerId);
this.clients = response.data != null && response.data.length > 0 ? response.data : []; this.clients = response.data != null && response.data.length > 0 ? response.data : [];
this.manageOrganizations = this.manageOrganizations = (await this.userService.getProvider(this.providerId)).type === ProviderUserType.ProviderAdmin;
(await this.providerService.get(this.providerId)).type === ProviderUserType.ProviderAdmin; const candidateOrgs = (await this.userService.getAllOrganizations()).filter(o => o.isOwner && o.providerId == null);
const candidateOrgs = (await this.organizationService.getAll()).filter( const allowedOrgsIds = await Promise.all(candidateOrgs.map(o => this.apiService.getOrganization(o.id))).then(orgs =>
(o) => o.isOwner && o.providerId == null orgs.filter(o => !DisallowedPlanTypes.includes(o.planType))
); .map(o => o.id));
const allowedOrgsIds = await Promise.all( this.addableOrganizations = candidateOrgs.filter(o => allowedOrgsIds.includes(o.id));
candidateOrgs.map((o) => this.apiService.getOrganization(o.id))
).then((orgs) =>
orgs.filter((o) => !DisallowedPlanTypes.includes(o.planType)).map((o) => o.id)
);
this.addableOrganizations = candidateOrgs.filter((o) => allowedOrgsIds.includes(o.id));
this.showAddExisting = this.addableOrganizations.length !== 0; this.showAddExisting = this.addableOrganizations.length !== 0;
this.loading = false; this.loading = false;
@@ -113,6 +106,7 @@ export class ClientsComponent implements OnInit {
this.loadMore(); this.loadMore();
} }
loadMore() { loadMore() {
if (!this.clients || this.clients.length <= this.pageSize) { if (!this.clients || this.clients.length <= this.pageSize) {
return; return;
@@ -123,19 +117,14 @@ export class ClientsComponent implements OnInit {
pagedSize = this.pagedClientsCount; pagedSize = this.pagedClientsCount;
} }
if (this.clients.length > pagedLength) { if (this.clients.length > pagedLength) {
this.pagedClients = this.pagedClients.concat( this.pagedClients = this.pagedClients.concat(this.clients.slice(pagedLength, pagedLength + pagedSize));
this.clients.slice(pagedLength, pagedLength + pagedSize)
);
} }
this.pagedClientsCount = this.pagedClients.length; this.pagedClientsCount = this.pagedClients.length;
this.didScroll = this.pagedClients.length > this.pageSize; this.didScroll = this.pagedClients.length > this.pageSize;
} }
async addExistingOrganization() { async addExistingOrganization() {
const [modal] = await this.modalService.openViewRef( const [modal] = await this.modalService.openViewRef(AddOrganizationComponent, this.addModalRef, comp => {
AddOrganizationComponent,
this.addModalRef,
(comp) => {
comp.providerId = this.providerId; comp.providerId = this.providerId;
comp.organizations = this.addableOrganizations; comp.organizations = this.addableOrganizations;
comp.onAddedOrganization.subscribe(async () => { comp.onAddedOrganization.subscribe(async () => {
@@ -146,34 +135,22 @@ export class ClientsComponent implements OnInit {
this.logService.error(`Handled exception: ${e}`); this.logService.error(`Handled exception: ${e}`);
} }
}); });
} });
);
} }
async remove(organization: ProviderOrganizationOrganizationDetailsResponse) { async remove(organization: ProviderOrganizationOrganizationDetailsResponse) {
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t("detachOrganizationConfirmation"), this.i18nService.t('detachOrganizationConfirmation'), organization.organizationName,
organization.organizationName, this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
this.i18nService.t("yes"),
this.i18nService.t("no"),
"warning"
);
if (!confirmed) { if (!confirmed) {
return false; return false;
} }
this.actionPromise = this.webProviderService.detachOrganizastion( this.actionPromise = this.providerService.detachOrganizastion(this.providerId, organization.id);
this.providerId,
organization.id
);
try { try {
await this.actionPromise; await this.actionPromise;
this.platformUtilsService.showToast( this.toasterService.popAsync('success', null, this.i18nService.t('detachedOrganization', organization.organizationName));
"success",
null,
this.i18nService.t("detachedOrganization", organization.organizationName)
);
await this.load(); await this.load();
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);

View File

@@ -1,5 +1,5 @@
<div class="page-header"> <div class="page-header">
<h1>{{ "newClientOrganization" | i18n }}</h1> <h1>{{'newClientOrganization' | i18n}}</h1>
</div> </div>
<p>{{ "newClientOrganizationDesc" | i18n }}</p> <p>{{'newClientOrganizationDesc' | i18n}}</p>
<app-organization-plans [providerId]="providerId"></app-organization-plans> <app-organization-plans [providerId]="providerId"></app-organization-plans>

View File

@@ -1,22 +1,25 @@
import { Component, OnInit, ViewChild } from "@angular/core"; import {
import { ActivatedRoute } from "@angular/router"; Component,
OnInit,
ViewChild,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { OrganizationPlansComponent } from "src/app/settings/organization-plans.component"; import { OrganizationPlansComponent } from 'src/app/settings/organization-plans.component';
@Component({ @Component({
selector: "app-create-organization", selector: 'app-create-organization',
templateUrl: "create-organization.component.html", templateUrl: 'create-organization.component.html',
}) })
export class CreateOrganizationComponent implements OnInit { export class CreateOrganizationComponent implements OnInit {
@ViewChild(OrganizationPlansComponent, { static: true }) @ViewChild(OrganizationPlansComponent, { static: true }) orgPlansComponent: OrganizationPlansComponent;
orgPlansComponent: OrganizationPlansComponent;
providerId: string; providerId: string;
constructor(private route: ActivatedRoute) {} constructor(private route: ActivatedRoute) { }
ngOnInit() { ngOnInit() {
this.route.parent.params.subscribe(async (params) => { this.route.parent.params.subscribe(async params => {
this.providerId = params.providerId; this.providerId = params.providerId;
}); });
} }

View File

@@ -1,38 +1,31 @@
<div class="mt-5 d-flex justify-content-center" *ngIf="loading"> <div class="mt-5 d-flex justify-content-center" *ngIf="loading">
<div> <div>
<img class="mb-4 logo logo-themed" alt="Bitwarden" /> <img class="mb-4 logo logo-themed" alt="Bitwarden">
<p class="text-center"> <p class="text-center">
<i <i class="fa fa-spinner fa-spin fa-2x text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin bwi-2x text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</p> </p>
</div> </div>
</div> </div>
<div class="container" *ngIf="!loading && !authed"> <div class="container" *ngIf="!loading && !authed">
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "joinProvider" | i18n }}</p> <p class="lead text-center mb-4">{{'joinProvider' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<p class="text-center"> <p class="text-center">
{{ providerName }} {{providerName}}
<strong class="d-block mt-2">{{ email }}</strong> <strong class="d-block mt-2">{{email}}</strong>
</p> </p>
<p>{{ "joinProviderDesc" | i18n }}</p> <p>{{'joinProviderDesc' | i18n}}</p>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<a routerLink="/" [queryParams]="{ email: email }" class="btn btn-primary btn-block"> <a routerLink="/" [queryParams]="{email: email}" class="btn btn-primary btn-block">
{{ "logIn" | i18n }} {{'logIn' | i18n}}
</a> </a>
<a <a routerLink="/register" [queryParams]="{email: email}"
routerLink="/register" class="btn btn-primary btn-block ml-2 mt-0">
[queryParams]="{ email: email }" {{'createAccount' | i18n}}
class="btn btn-primary btn-block ml-2 mt-0"
>
{{ "createAccount" | i18n }}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,53 +1,45 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from '@angular/router';
import { Toast, ToasterService } from 'angular2-toaster';
import { BaseAcceptComponent } from "src/app/common/base.accept.component"; import { BaseAcceptComponent } from 'src/app/common/base.accept.component';
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 { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { StateService } from 'jslib-common/abstractions/state.service';
import { StateService } from "jslib-common/abstractions/state.service"; import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderUserAcceptRequest } from "jslib-common/models/request/provider/providerUserAcceptRequest"; import { ProviderUserAcceptRequest } from 'jslib-common/models/request/provider/providerUserAcceptRequest';
@Component({ @Component({
selector: "app-accept-provider", selector: 'app-accept-provider',
templateUrl: "accept-provider.component.html", templateUrl: 'accept-provider.component.html',
}) })
export class AcceptProviderComponent extends BaseAcceptComponent { export class AcceptProviderComponent extends BaseAcceptComponent {
providerName: string; providerName: string;
failedMessage = "providerInviteAcceptFailed"; failedMessage = 'providerInviteAcceptFailed';
requiredParameters = ["providerId", "providerUserId", "token"]; requiredParameters = ['providerId', 'providerUserId', 'token'];
constructor( constructor(router: Router, toasterService: ToasterService, i18nService: I18nService, route: ActivatedRoute,
router: Router, userService: UserService, stateService: StateService, private apiService: ApiService) {
i18nService: I18nService, super(router, toasterService, i18nService, route, userService, stateService);
route: ActivatedRoute,
stateService: StateService,
private apiService: ApiService,
platformUtilService: PlatformUtilsService
) {
super(router, platformUtilService, i18nService, route, stateService);
} }
async authedHandler(qParams: any) { async authedHandler(qParams: any) {
const request = new ProviderUserAcceptRequest(); const request = new ProviderUserAcceptRequest();
request.token = qParams.token; request.token = qParams.token;
await this.apiService.postProviderUserAccept( await this.apiService.postProviderUserAccept(qParams.providerId, qParams.providerUserId, request);
qParams.providerId, const toast: Toast = {
qParams.providerUserId, type: 'success',
request title: this.i18nService.t('inviteAccepted'),
); body: this.i18nService.t('providerInviteAcceptedDesc'),
this.platformUtilService.showToast( timeout: 10000,
"success", };
this.i18nService.t("inviteAccepted"), this.toasterService.popAsync(toast);
this.i18nService.t("providerInviteAcceptedDesc"), this.router.navigate(['/vault']);
{ timeout: 10000 }
);
this.router.navigate(["/vault"]);
} }
async unauthedHandler(qParams: any) { async unauthedHandler(qParams: any) {

View File

@@ -1,17 +1,21 @@
import { Component, Input } from "@angular/core"; import {
Component,
Input,
} from '@angular/core';
import { ProviderUserBulkConfirmRequest } from "jslib-common/models/request/provider/providerUserBulkConfirmRequest"; import { ProviderUserBulkConfirmRequest } from 'jslib-common/models/request/provider/providerUserBulkConfirmRequest';
import { ProviderUserBulkRequest } from "jslib-common/models/request/provider/providerUserBulkRequest"; import { ProviderUserBulkRequest } from 'jslib-common/models/request/provider/providerUserBulkRequest';
import { ProviderUserStatusType } from "jslib-common/enums/providerUserStatusType"; import { ProviderUserStatusType } from 'jslib-common/enums/providerUserStatusType';
import { BulkConfirmComponent as OrganizationBulkConfirmComponent } from "src/app/organizations/manage/bulk/bulk-confirm.component"; import { BulkConfirmComponent as OrganizationBulkConfirmComponent } from 'src/app/organizations/manage/bulk/bulk-confirm.component';
import { BulkUserDetails } from "src/app/organizations/manage/bulk/bulk-status.component"; import { BulkUserDetails } from 'src/app/organizations/manage/bulk/bulk-status.component';
@Component({ @Component({
templateUrl: "../../../../../../src/app/organizations/manage/bulk/bulk-confirm.component.html", templateUrl: '/src/app/organizations/manage/bulk/bulk-confirm.component.html',
}) })
export class BulkConfirmComponent extends OrganizationBulkConfirmComponent { export class BulkConfirmComponent extends OrganizationBulkConfirmComponent {
@Input() providerId: string; @Input() providerId: string;
protected isAccepted(user: BulkUserDetails) { protected isAccepted(user: BulkUserDetails) {
@@ -19,7 +23,7 @@ export class BulkConfirmComponent extends OrganizationBulkConfirmComponent {
} }
protected async getPublicKeys() { protected async getPublicKeys() {
const request = new ProviderUserBulkRequest(this.filteredUsers.map((user) => user.id)); const request = new ProviderUserBulkRequest(this.filteredUsers.map(user => user.id));
return await this.apiService.postProviderUsersPublicKey(this.providerId, request); return await this.apiService.postProviderUsersPublicKey(this.providerId, request);
} }

View File

@@ -1,17 +1,21 @@
import { Component, Input } from "@angular/core"; import {
Component,
Input,
} from '@angular/core';
import { ProviderUserBulkRequest } from "jslib-common/models/request/provider/providerUserBulkRequest"; import { ProviderUserBulkRequest } from 'jslib-common/models/request/provider/providerUserBulkRequest';
import { BulkRemoveComponent as OrganizationBulkRemoveComponent } from "src/app/organizations/manage/bulk/bulk-remove.component"; import { BulkRemoveComponent as OrganizationBulkRemoveComponent } from 'src/app/organizations/manage/bulk/bulk-remove.component';
@Component({ @Component({
templateUrl: "../../../../../../src/app/organizations/manage/bulk/bulk-remove.component.html", templateUrl: '/src/app/organizations/manage/bulk/bulk-remove.component.html',
}) })
export class BulkRemoveComponent extends OrganizationBulkRemoveComponent { export class BulkRemoveComponent extends OrganizationBulkRemoveComponent {
@Input() providerId: string; @Input() providerId: string;
async deleteUsers() { async deleteUsers() {
const request = new ProviderUserBulkRequest(this.users.map((user) => user.id)); const request = new ProviderUserBulkRequest(this.users.map(user => user.id));
return await this.apiService.deleteManyProviderUsers(this.providerId, request); return await this.apiService.deleteManyProviderUsers(this.providerId, request);
} }
} }

View File

@@ -1,107 +1,68 @@
<div class="page-header d-flex"> <div class="page-header d-flex">
<h1>{{ "eventLogs" | i18n }}</h1> <h1>{{'eventLogs' | i18n}}</h1>
<div class="ml-auto d-flex"> <div class="ml-auto d-flex">
<div class="form-inline"> <div class="form-inline">
<label class="sr-only" for="start">{{ "startDate" | i18n }}</label> <label class="sr-only" for="start">{{'startDate' | i18n}}</label>
<input <input type="datetime-local" class="form-control form-control-sm" id="start"
type="datetime-local" placeholder="{{'startDate' | i18n}}" [(ngModel)]="start" placeholder="YYYY-MM-DDTHH:MM"
class="form-control form-control-sm" (change)="dirtyDates = true">
id="start"
placeholder="{{ 'startDate' | i18n }}"
[(ngModel)]="start"
placeholder="YYYY-MM-DDTHH:MM"
(change)="dirtyDates = true"
/>
<span class="mx-2">-</span> <span class="mx-2">-</span>
<label class="sr-only" for="end">{{ "endDate" | i18n }}</label> <label class="sr-only" for="end">{{'endDate' | i18n}}</label>
<input <input type="datetime-local" class="form-control form-control-sm" id="end"
type="datetime-local" placeholder="{{'endDate' | i18n}}" [(ngModel)]="end" placeholder="YYYY-MM-DDTHH:MM"
class="form-control form-control-sm" (change)="dirtyDates = true">
id="end"
placeholder="{{ 'endDate' | i18n }}"
[(ngModel)]="end"
placeholder="YYYY-MM-DDTHH:MM"
(change)="dirtyDates = true"
/>
</div> </div>
<form #refreshForm [appApiAction]="refreshPromise" class="d-inline"> <form #refreshForm [appApiAction]="refreshPromise" class="d-inline">
<button <button type="button" class="btn btn-sm btn-outline-primary ml-3" (click)="loadEvents(true)"
type="button" [disabled]="loaded && refreshForm.loading">
class="btn btn-sm btn-outline-primary ml-3" <i class="fa fa-refresh fa-fw" aria-hidden="true" [ngClass]="{'fa-spin': loaded && refreshForm.loading}"></i>
(click)="loadEvents(true)" {{'refresh' | i18n}}
[disabled]="loaded && refreshForm.loading"
>
<i
class="bwi bwi-refresh bwi-fw"
aria-hidden="true"
[ngClass]="{ 'bwi-spin': loaded && refreshForm.loading }"
></i>
{{ "refresh" | i18n }}
</button> </button>
</form> </form>
<form #exportForm [appApiAction]="exportPromise" class="d-inline"> <form #exportForm [appApiAction]="exportPromise" class="d-inline">
<button <button type="button" class="btn btn-sm btn-outline-primary btn-submit manual ml-3"
type="button" [ngClass]="{loading:exportForm.loading}" (click)="exportEvents()"
class="btn btn-sm btn-outline-primary btn-submit manual ml-3" [disabled]="loaded && exportForm.loading || dirtyDates">
[ngClass]="{ loading: exportForm.loading }" <i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
(click)="exportEvents()" <span>{{'export' | i18n}}</span>
[disabled]="(loaded && exportForm.loading) || dirtyDates"
>
<i class="bwi bwi-spinner bwi-spin" aria-hidden="true"></i>
<span>{{ "export" | i18n }}</span>
</button> </button>
</form> </form>
</div> </div>
</div> </div>
<ng-container *ngIf="!loaded"> <ng-container *ngIf="!loaded">
<i <i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</ng-container> </ng-container>
<ng-container *ngIf="loaded"> <ng-container *ngIf="loaded">
<p *ngIf="!events || !events.length">{{ "noEventsInList" | i18n }}</p> <p *ngIf="!events || !events.length">{{'noEventsInList' | i18n}}</p>
<table class="table table-hover" *ngIf="events && events.length"> <table class="table table-hover" *ngIf="events && events.length">
<thead> <thead>
<tr> <tr>
<th class="border-top-0" width="210">{{ "timestamp" | i18n }}</th> <th class="border-top-0" width="210">{{'timestamp' | i18n}}</th>
<th class="border-top-0" width="40"> <th class="border-top-0" width="40">
<span class="sr-only">{{ "device" | i18n }}</span> <span class="sr-only">{{'device' | i18n}}</span>
</th> </th>
<th class="border-top-0" width="150">{{ "user" | i18n }}</th> <th class="border-top-0" width="150">{{'user' | i18n}}</th>
<th class="border-top-0">{{ "event" | i18n }}</th> <th class="border-top-0">{{'event' | i18n}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let e of events"> <tr *ngFor="let e of events">
<td>{{ e.date | date: "medium" }}</td> <td>{{e.date | date:'medium'}}</td>
<td> <td>
<i <i class="text-muted fa fa-lg {{e.appIcon}}" title="{{e.appName}}, {{e.ip}}" aria-hidden="true"></i>
class="text-muted bwi bwi-lg {{ e.appIcon }}" <span class="sr-only">{{e.appName}}, {{e.ip}}</span>
title="{{ e.appName }}, {{ e.ip }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ e.appName }}, {{ e.ip }}</span>
</td> </td>
<td> <td>
<span title="{{ e.userEmail }}">{{ e.userName }}</span> <span title="{{e.userEmail}}">{{e.userName}}</span>
</td> </td>
<td [innerHTML]="e.message"></td> <td [innerHTML]="e.message"></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<button <button #moreBtn [appApiAction]="morePromise" type="button" class="btn btn-block btn-link btn-submit"
#moreBtn (click)="loadEvents(false)" [disabled]="loaded && moreBtn.loading" *ngIf="continuationToken">
[appApiAction]="morePromise" <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
type="button" <span>{{'loadMore' | i18n}}</span>
class="btn btn-block btn-link btn-submit"
(click)="loadEvents(false)"
[disabled]="loaded && moreBtn.loading"
*ngIf="continuationToken"
>
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
<span>{{ "loadMore" | i18n }}</span>
</button> </button>
</ng-container> </ng-container>

View File

@@ -1,53 +1,49 @@
import { Component, OnInit } from "@angular/core"; import {
import { ActivatedRoute, Router } from "@angular/router"; Component,
OnInit,
} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { ExportService } from "jslib-common/abstractions/export.service"; import { ExportService } from 'jslib-common/abstractions/export.service';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from "jslib-common/abstractions/log.service"; import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { UserService } from 'jslib-common/abstractions/user.service';
import { UserNamePipe } from "jslib-angular/pipes/user-name.pipe"; import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import { EventResponse } from "jslib-common/models/response/eventResponse"; import { EventResponse } from 'jslib-common/models/response/eventResponse';
import { EventService } from "src/app/services/event.service"; import { EventService } from 'src/app/services/event.service';
import { BaseEventsComponent } from "src/app/common/base.events.component"; import { BaseEventsComponent } from 'src/app/common/base.events.component';
@Component({ @Component({
selector: "provider-events", selector: 'provider-events',
templateUrl: "events.component.html", templateUrl: 'events.component.html',
}) })
export class EventsComponent extends BaseEventsComponent implements OnInit { export class EventsComponent extends BaseEventsComponent implements OnInit {
exportFileName: string = "provider-events"; exportFileName: string = 'provider-events';
providerId: string; providerId: string;
private providerUsersUserIdMap = new Map<string, any>(); private providerUsersUserIdMap = new Map<string, any>();
private providerUsersIdMap = new Map<string, any>(); private providerUsersIdMap = new Map<string, any>();
constructor( constructor(private apiService: ApiService, private route: ActivatedRoute, eventService: EventService,
private apiService: ApiService, i18nService: I18nService, toasterService: ToasterService, private userService: UserService,
private route: ActivatedRoute, exportService: ExportService, platformUtilsService: PlatformUtilsService, private router: Router,
eventService: EventService, logService: LogService, private userNamePipe: UserNamePipe) {
i18nService: I18nService, super(eventService, i18nService, toasterService, exportService, platformUtilsService, logService);
private providerService: ProviderService,
exportService: ExportService,
platformUtilsService: PlatformUtilsService,
private router: Router,
logService: LogService,
private userNamePipe: UserNamePipe
) {
super(eventService, i18nService, exportService, platformUtilsService, logService);
} }
async ngOnInit() { async ngOnInit() {
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async params => {
this.providerId = params.providerId; this.providerId = params.providerId;
const provider = await this.providerService.get(this.providerId); const provider = await this.userService.getProvider(this.providerId);
if (provider == null || !provider.useEvents) { if (provider == null || !provider.useEvents) {
this.router.navigate(["/providers", this.providerId]); this.router.navigate(['/providers', this.providerId]);
return; return;
} }
await this.load(); await this.load();
@@ -56,7 +52,7 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
async load() { async load() {
const response = await this.apiService.getProviderUsers(this.providerId); const response = await this.apiService.getProviderUsers(this.providerId);
response.data.forEach((u) => { response.data.forEach(u => {
const name = this.userNamePipe.transform(u); const name = this.userNamePipe.transform(u);
this.providerUsersIdMap.set(u.id, { name: name, email: u.email }); this.providerUsersIdMap.set(u.id, { name: name, email: u.email });
this.providerUsersUserIdMap.set(u.userId, { name: name, email: u.email }); this.providerUsersUserIdMap.set(u.userId, { name: name, email: u.email });
@@ -66,17 +62,10 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
} }
protected requestEvents(startDate: string, endDate: string, continuationToken: string) { protected requestEvents(startDate: string, endDate: string, continuationToken: string) {
return this.apiService.getEventsProvider( return this.apiService.getEventsProvider(this.providerId, startDate, endDate, continuationToken);
this.providerId,
startDate,
endDate,
continuationToken
);
} }
protected getUserName(r: EventResponse, userId: string) { protected getUserName(r: EventResponse, userId: string) {
return userId != null && this.providerUsersUserIdMap.has(userId) return userId != null && this.providerUsersUserIdMap.has(userId) ? this.providerUsersUserIdMap.get(userId) : null;
? this.providerUsersUserIdMap.get(userId)
: null;
} }
} }

View File

@@ -2,23 +2,15 @@
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
<div class="card" *ngIf="provider"> <div class="card" *ngIf="provider">
<div class="card-header">{{ "manage" | i18n }}</div> <div class="card-header">{{'manage' | i18n}}</div>
<div class="list-group list-group-flush"> <div class="list-group list-group-flush">
<a <a routerLink="people" class="list-group-item" routerLinkActive="active"
routerLink="people" *ngIf="provider.canManageUsers">
class="list-group-item" {{'people' | i18n}}
routerLinkActive="active"
*ngIf="provider.canManageUsers"
>
{{ "people" | i18n }}
</a> </a>
<a <a routerLink="events" class="list-group-item" routerLinkActive="active"
routerLink="events" *ngIf="provider.canAccessEventLogs && accessEvents">
class="list-group-item" {{'eventLogs' | i18n}}
routerLinkActive="active"
*ngIf="provider.canAccessEventLogs && accessEvents"
>
{{ "eventLogs" | i18n }}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,23 +1,26 @@
import { Component, OnInit } from "@angular/core"; import {
import { ActivatedRoute } from "@angular/router"; Component,
OnInit,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { UserService } from 'jslib-common/abstractions/user.service';
import { Provider } from "jslib-common/models/domain/provider"; import { Provider } from 'jslib-common/models/domain/provider';
@Component({ @Component({
selector: "provider-manage", selector: 'provider-manage',
templateUrl: "manage.component.html", templateUrl: 'manage.component.html',
}) })
export class ManageComponent implements OnInit { export class ManageComponent implements OnInit {
provider: Provider; provider: Provider;
accessEvents = false; accessEvents = false;
constructor(private route: ActivatedRoute, private providerService: ProviderService) {} constructor(private route: ActivatedRoute, private userService: UserService) { }
ngOnInit() { ngOnInit() {
this.route.parent.params.subscribe(async (params) => { this.route.parent.params.subscribe(async params => {
this.provider = await this.providerService.get(params.providerId); this.provider = await this.userService.getProvider(params.providerId);
this.accessEvents = this.provider.useEvents; this.accessEvents = this.provider.useEvents;
}); });
} }

View File

@@ -1,221 +1,137 @@
<div class="page-header d-flex"> <div class="page-header d-flex">
<h1>{{ "people" | i18n }}</h1> <h1>{{'people' | i18n}}</h1>
<div class="ml-auto d-flex"> <div class="ml-auto d-flex">
<div class="btn-group btn-group-sm" role="group"> <div class="btn-group btn-group-sm" role="group">
<button <button type="button" class="btn btn-outline-secondary" [ngClass]="{active: status == null}"
type="button" (click)="filter(null)">
class="btn btn-outline-secondary" {{'all' | i18n}}
[ngClass]="{ active: status == null }" <span class="badge badge-pill badge-info" *ngIf="allCount">{{allCount}}</span>
(click)="filter(null)"
>
{{ "all" | i18n }}
<span class="badge badge-pill badge-info" *ngIf="allCount">{{ allCount }}</span>
</button> </button>
<button <button type="button" class="btn btn-outline-secondary"
type="button" [ngClass]="{active: status == userStatusType.Invited}"
class="btn btn-outline-secondary" (click)="filter(userStatusType.Invited)">
[ngClass]="{ active: status == userStatusType.Invited }" {{'invited' | i18n}}
(click)="filter(userStatusType.Invited)" <span class="badge badge-pill badge-info" *ngIf="invitedCount">{{invitedCount}}</span>
>
{{ "invited" | i18n }}
<span class="badge badge-pill badge-info" *ngIf="invitedCount">{{ invitedCount }}</span>
</button> </button>
<button <button type="button" class="btn btn-outline-secondary"
type="button" [ngClass]="{active: status == userStatusType.Accepted}"
class="btn btn-outline-secondary" (click)="filter(userStatusType.Accepted)">
[ngClass]="{ active: status == userStatusType.Accepted }" {{'accepted' | i18n}}
(click)="filter(userStatusType.Accepted)" <span class="badge badge-pill badge-warning" *ngIf="acceptedCount">{{acceptedCount}}</span>
>
{{ "accepted" | i18n }}
<span class="badge badge-pill badge-warning" *ngIf="acceptedCount">{{
acceptedCount
}}</span>
</button> </button>
</div> </div>
<div class="ml-3"> <div class="ml-3">
<label class="sr-only" for="search">{{ "search" | i18n }}</label> <label class="sr-only" for="search">{{'search' | i18n}}</label>
<input <input type="search" class="form-control form-control-sm" id="search" placeholder="{{'search' | i18n}}"
type="search" [(ngModel)]="searchText">
class="form-control form-control-sm"
id="search"
placeholder="{{ 'search' | i18n }}"
[(ngModel)]="searchText"
/>
</div> </div>
<div class="dropdown ml-3" appListDropdown> <div class="dropdown ml-3" appListDropdown>
<button <button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" id="bulkActionsButton"
class="btn btn-sm btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" appA11yTitle="{{'options' | i18n}}">
type="button" <i class="fa fa-cog" aria-hidden="true"></i>
id="bulkActionsButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
appA11yTitle="{{ 'options' | i18n }}"
>
<i class="bwi bwi-cog" aria-hidden="true"></i>
</button> </button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="bulkActionsButton"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="bulkActionsButton">
<button class="dropdown-item" appStopClick (click)="bulkReinvite()"> <button class="dropdown-item" appStopClick (click)="bulkReinvite()">
<i class="bwi bwi-fw bwi-envelope" aria-hidden="true"></i> <i class="fa fa-fw fa-envelope-o" aria-hidden="true"></i>
{{ "reinviteSelected" | i18n }} {{'reinviteSelected' | i18n}}
</button> </button>
<button <button class="dropdown-item text-success" appStopClick (click)="bulkConfirm()"
class="dropdown-item text-success" *ngIf="showBulkConfirmUsers">
appStopClick <i class="fa fa-fw fa-check" aria-hidden="true"></i>
(click)="bulkConfirm()" {{'confirmSelected' | i18n}}
*ngIf="showBulkConfirmUsers"
>
<i class="bwi bwi-fw bwi-check" aria-hidden="true"></i>
{{ "confirmSelected" | i18n }}
</button> </button>
<button class="dropdown-item text-danger" appStopClick (click)="bulkRemove()"> <button class="dropdown-item text-danger" appStopClick (click)="bulkRemove()">
<i class="bwi bwi-fw bwi-close" aria-hidden="true"></i> <i class="fa fa-fw fa-remove" aria-hidden="true"></i>
{{ "remove" | i18n }} {{'remove' | i18n}}
</button> </button>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<button class="dropdown-item" appStopClick (click)="selectAll(true)"> <button class="dropdown-item" appStopClick (click)="selectAll(true)">
<i class="bwi bwi-fw bwi-check-square" aria-hidden="true"></i> <i class="fa fa-fw fa-check-square-o" aria-hidden="true"></i>
{{ "selectAll" | i18n }} {{'selectAll' | i18n}}
</button> </button>
<button class="dropdown-item" appStopClick (click)="selectAll(false)"> <button class="dropdown-item" appStopClick (click)="selectAll(false)">
<i class="bwi bwi-fw bwi-minus-square" aria-hidden="true"></i> <i class="fa fa-fw fa-minus-square-o" aria-hidden="true"></i>
{{ "unselectAll" | i18n }} {{'unselectAll' | i18n}}
</button> </button>
</div> </div>
</div> </div>
<button type="button" class="btn btn-sm btn-outline-primary ml-3" (click)="invite()"> <button type="button" class="btn btn-sm btn-outline-primary ml-3" (click)="invite()">
<i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i> <i class="fa fa-plus fa-fw" aria-hidden="true"></i>
{{ "inviteUser" | i18n }} {{'inviteUser' | i18n}}
</button> </button>
</div> </div>
</div> </div>
<ng-container *ngIf="loading"> <ng-container *ngIf="loading">
<i <i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</ng-container> </ng-container>
<ng-container <ng-container
*ngIf=" *ngIf="!loading && (isPaging() ? pagedUsers : users | search:searchText:'name':'email':'id') as searchedUsers">
!loading && <p *ngIf="!searchedUsers.length">{{'noUsersInList' | i18n}}</p>
(isPaging() ? pagedUsers : (users | search: searchText:'name':'email':'id')) as searchedUsers
"
>
<p *ngIf="!searchedUsers.length">{{ "noUsersInList" | i18n }}</p>
<ng-container *ngIf="searchedUsers.length"> <ng-container *ngIf="searchedUsers.length">
<app-callout <app-callout type="info" title="{{'confirmUsers' | i18n}}" icon="fa-check-circle" *ngIf="showConfirmUsers">
type="info" {{'providerUsersNeedConfirmed' | i18n}}
title="{{ 'confirmUsers' | i18n }}"
icon="bwi bwi-check-circle"
*ngIf="showConfirmUsers"
>
{{ "providerUsersNeedConfirmed" | i18n }}
</app-callout> </app-callout>
<table <table class="table table-hover table-list" infiniteScroll [infiniteScrollDistance]="1"
class="table table-hover table-list" [infiniteScrollDisabled]="!isPaging()" (scrolled)="loadMore()">
infiniteScroll
[infiniteScrollDistance]="1"
[infiniteScrollDisabled]="!isPaging()"
(scrolled)="loadMore()"
>
<tbody> <tbody>
<tr *ngFor="let u of searchedUsers"> <tr *ngFor="let u of searchedUsers">
<td (click)="checkUser(u)" class="table-list-checkbox"> <td (click)="checkUser(u)" class="table-list-checkbox">
<input type="checkbox" [(ngModel)]="u.checked" appStopProp /> <input type="checkbox" [(ngModel)]="u.checked" appStopProp>
</td> </td>
<td width="30"> <td width="30">
<app-avatar <app-avatar [data]="u | userName" [email]="u.email" size="25" [circle]="true"
[data]="u | userName" [fontSize]="14"></app-avatar>
[email]="u.email"
size="25"
[circle]="true"
[fontSize]="14"
>
</app-avatar>
</td> </td>
<td> <td>
<a href="#" appStopClick (click)="edit(u)">{{ u.email }}</a> <a href="#" appStopClick (click)="edit(u)">{{u.email}}</a>
<span class="badge badge-secondary" *ngIf="u.status === userStatusType.Invited">{{ <span class="badge badge-secondary"
"invited" | i18n *ngIf="u.status === userStatusType.Invited">{{'invited' | i18n}}</span>
}}</span> <span class="badge badge-warning"
<span class="badge badge-warning" *ngIf="u.status === userStatusType.Accepted">{{ *ngIf="u.status === userStatusType.Accepted">{{'accepted' | i18n}}</span>
"accepted" | i18n <small class="text-muted d-block" *ngIf="u.name">{{u.name}}</small>
}}</span>
<small class="text-muted d-block" *ngIf="u.name">{{ u.name }}</small>
</td> </td>
<td> <td>
<ng-container *ngIf="u.twoFactorEnabled"> <ng-container *ngIf="u.twoFactorEnabled">
<i <i class="fa fa-lock" title="{{'userUsingTwoStep' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-lock" <span class="sr-only">{{'userUsingTwoStep' | i18n}}</span>
title="{{ 'userUsingTwoStep' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "userUsingTwoStep" | i18n }}</span>
</ng-container> </ng-container>
</td> </td>
<td> <td>
<span *ngIf="u.type === userType.ProviderAdmin">{{ "providerAdmin" | i18n }}</span> <span *ngIf="u.type === userType.ProviderAdmin">{{'providerAdmin' | i18n}}</span>
<span *ngIf="u.type === userType.ServiceUser">{{ "serviceUser" | i18n }}</span> <span *ngIf="u.type === userType.ServiceUser">{{'serviceUser' | i18n}}</span>
<span *ngIf="u.type === userType.Custom">{{ "custom" | i18n }}</span> <span *ngIf="u.type === userType.Custom">{{'custom' | i18n}}</span>
</td> </td>
<td class="table-list-options"> <td class="table-list-options">
<div class="dropdown" appListDropdown> <div class="dropdown" appListDropdown>
<button <button class="btn btn-outline-secondary dropdown-toggle" type="button"
class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
type="button" appA11yTitle="{{'options' | i18n}}">
data-toggle="dropdown" <i class="fa fa-cog fa-lg" aria-hidden="true"></i>
aria-haspopup="true"
aria-expanded="false"
appA11yTitle="{{ 'options' | i18n }}"
>
<i class="bwi bwi-cog bwi-lg" aria-hidden="true"></i>
</button> </button>
<div class="dropdown-menu dropdown-menu-right"> <div class="dropdown-menu dropdown-menu-right">
<a <a class="dropdown-item" href="#" appStopClick (click)="reinvite(u)"
class="dropdown-item" *ngIf="u.status === userStatusType.Invited">
href="#" <i class="fa fa-fw fa-envelope-o" aria-hidden="true"></i>
appStopClick {{'resendInvitation' | i18n}}
(click)="reinvite(u)"
*ngIf="u.status === userStatusType.Invited"
>
<i class="bwi bwi-fw bwi-envelope" aria-hidden="true"></i>
{{ "resendInvitation" | i18n }}
</a> </a>
<a <a class="dropdown-item text-success" href="#" appStopClick (click)="confirm(u)"
class="dropdown-item text-success" *ngIf="u.status === userStatusType.Accepted">
href="#" <i class="fa fa-fw fa-check" aria-hidden="true"></i>
appStopClick {{'confirm' | i18n}}
(click)="confirm(u)"
*ngIf="u.status === userStatusType.Accepted"
>
<i class="bwi bwi-fw bwi-check" aria-hidden="true"></i>
{{ "confirm" | i18n }}
</a> </a>
<a <a class="dropdown-item" href="#" appStopClick (click)="groups(u)" *ngIf="accessGroups">
class="dropdown-item" <i class="fa fa-fw fa-sitemap" aria-hidden="true"></i>
href="#" {{'groups' | i18n}}
appStopClick
(click)="groups(u)"
*ngIf="accessGroups"
>
<i class="bwi bwi-fw bwi-sitemap" aria-hidden="true"></i>
{{ "groups" | i18n }}
</a> </a>
<a <a class="dropdown-item" href="#" appStopClick (click)="events(u)"
class="dropdown-item" *ngIf="accessEvents && u.status === userStatusType.Confirmed">
href="#" <i class="fa fa-fw fa-file-text-o" aria-hidden="true"></i>
appStopClick {{'eventLogs' | i18n}}
(click)="events(u)"
*ngIf="accessEvents && u.status === userStatusType.Confirmed"
>
<i class="bwi bwi-fw bwi-file-text" aria-hidden="true"></i>
{{ "eventLogs" | i18n }}
</a> </a>
<a class="dropdown-item text-danger" href="#" appStopClick (click)="remove(u)"> <a class="dropdown-item text-danger" href="#" appStopClick (click)="remove(u)">
<i class="bwi bwi-fw bwi-remove" aria-hidden="true"></i> <i class="fa fa-fw fa-remove" aria-hidden="true"></i>
{{ "remove" | i18n }} {{'remove' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,103 +1,79 @@
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core"; import {
import { ActivatedRoute, Router } from "@angular/router"; Component,
OnInit,
ViewChild,
ViewContainerRef
} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster';
import { first } from "rxjs/operators"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ModalService } from 'jslib-angular/services/modal.service';
import { CryptoService } from "jslib-common/abstractions/crypto.service"; import { ValidationService } from 'jslib-angular/services/validation.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { ProviderService } from "jslib-common/abstractions/provider.service";
import { SearchService } from "jslib-common/abstractions/search.service";
import { StateService } from "jslib-common/abstractions/state.service";
import { ModalService } from "jslib-angular/services/modal.service"; import { ProviderUserStatusType } from 'jslib-common/enums/providerUserStatusType';
import { ValidationService } from "jslib-angular/services/validation.service"; import { ProviderUserType } from 'jslib-common/enums/providerUserType';
import { ProviderUserStatusType } from "jslib-common/enums/providerUserStatusType"; import { SearchPipe } from 'jslib-angular/pipes/search.pipe';
import { ProviderUserType } from "jslib-common/enums/providerUserType"; import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
import { SearchPipe } from "jslib-angular/pipes/search.pipe"; import { ListResponse } from 'jslib-common/models/response/listResponse';
import { UserNamePipe } from "jslib-angular/pipes/user-name.pipe"; import { ProviderUserUserDetailsResponse } from 'jslib-common/models/response/provider/providerUserResponse';
import { ListResponse } from "jslib-common/models/response/listResponse"; import { ProviderUserBulkRequest } from 'jslib-common/models/request/provider/providerUserBulkRequest';
import { ProviderUserUserDetailsResponse } from "jslib-common/models/response/provider/providerUserResponse"; import { ProviderUserConfirmRequest } from 'jslib-common/models/request/provider/providerUserConfirmRequest';
import { ProviderUserBulkResponse } from 'jslib-common/models/response/provider/providerUserBulkResponse';
import { ProviderUserBulkRequest } from "jslib-common/models/request/provider/providerUserBulkRequest"; import { BasePeopleComponent } from 'src/app/common/base.people.component';
import { ProviderUserConfirmRequest } from "jslib-common/models/request/provider/providerUserConfirmRequest"; import { BulkStatusComponent } from 'src/app/organizations/manage/bulk/bulk-status.component';
import { ProviderUserBulkResponse } from "jslib-common/models/response/provider/providerUserBulkResponse"; import { EntityEventsComponent } from 'src/app/organizations/manage/entity-events.component';
import { BulkConfirmComponent } from './bulk/bulk-confirm.component';
import { BasePeopleComponent } from "src/app/common/base.people.component"; import { BulkRemoveComponent } from './bulk/bulk-remove.component';
import { BulkStatusComponent } from "src/app/organizations/manage/bulk/bulk-status.component"; import { UserAddEditComponent } from './user-add-edit.component';
import { EntityEventsComponent } from "src/app/organizations/manage/entity-events.component";
import { BulkConfirmComponent } from "./bulk/bulk-confirm.component";
import { BulkRemoveComponent } from "./bulk/bulk-remove.component";
import { UserAddEditComponent } from "./user-add-edit.component";
@Component({ @Component({
selector: "provider-people", selector: 'provider-people',
templateUrl: "people.component.html", templateUrl: 'people.component.html',
}) })
export class PeopleComponent export class PeopleComponent extends BasePeopleComponent<ProviderUserUserDetailsResponse> implements OnInit {
extends BasePeopleComponent<ProviderUserUserDetailsResponse>
implements OnInit @ViewChild('addEdit', { read: ViewContainerRef, static: true }) addEditModalRef: ViewContainerRef;
{ @ViewChild('groupsTemplate', { read: ViewContainerRef, static: true }) groupsModalRef: ViewContainerRef;
@ViewChild("addEdit", { read: ViewContainerRef, static: true }) addEditModalRef: ViewContainerRef; @ViewChild('eventsTemplate', { read: ViewContainerRef, static: true }) eventsModalRef: ViewContainerRef;
@ViewChild("groupsTemplate", { read: ViewContainerRef, static: true }) @ViewChild('bulkStatusTemplate', { read: ViewContainerRef, static: true }) bulkStatusModalRef: ViewContainerRef;
groupsModalRef: ViewContainerRef; @ViewChild('bulkConfirmTemplate', { read: ViewContainerRef, static: true }) bulkConfirmModalRef: ViewContainerRef;
@ViewChild("eventsTemplate", { read: ViewContainerRef, static: true }) @ViewChild('bulkRemoveTemplate', { read: ViewContainerRef, static: true }) bulkRemoveModalRef: ViewContainerRef;
eventsModalRef: ViewContainerRef;
@ViewChild("bulkStatusTemplate", { read: ViewContainerRef, static: true })
bulkStatusModalRef: ViewContainerRef;
@ViewChild("bulkConfirmTemplate", { read: ViewContainerRef, static: true })
bulkConfirmModalRef: ViewContainerRef;
@ViewChild("bulkRemoveTemplate", { read: ViewContainerRef, static: true })
bulkRemoveModalRef: ViewContainerRef;
userType = ProviderUserType; userType = ProviderUserType;
userStatusType = ProviderUserStatusType; userStatusType = ProviderUserStatusType;
providerId: string; providerId: string;
accessEvents = false; accessEvents = false;
constructor( constructor(apiService: ApiService, private route: ActivatedRoute,
apiService: ApiService, i18nService: I18nService, modalService: ModalService,
private route: ActivatedRoute, platformUtilsService: PlatformUtilsService, toasterService: ToasterService,
i18nService: I18nService, cryptoService: CryptoService, private userService: UserService, private router: Router,
modalService: ModalService, storageService: StorageService, searchService: SearchService, validationService: ValidationService,
platformUtilsService: PlatformUtilsService, logService: LogService, searchPipe: SearchPipe, userNamePipe: UserNamePipe) {
cryptoService: CryptoService, super(apiService, searchService, i18nService, platformUtilsService, toasterService, cryptoService,
private router: Router, storageService, validationService, modalService, logService, searchPipe, userNamePipe);
searchService: SearchService,
validationService: ValidationService,
logService: LogService,
searchPipe: SearchPipe,
userNamePipe: UserNamePipe,
stateService: StateService,
private providerService: ProviderService
) {
super(
apiService,
searchService,
i18nService,
platformUtilsService,
cryptoService,
validationService,
modalService,
logService,
searchPipe,
userNamePipe,
stateService
);
} }
ngOnInit() { ngOnInit() {
this.route.parent.params.subscribe(async (params) => { this.route.parent.params.subscribe(async params => {
this.providerId = params.providerId; this.providerId = params.providerId;
const provider = await this.providerService.get(this.providerId); const provider = await this.userService.getProvider(this.providerId);
if (!provider.canManageUsers) { if (!provider.canManageUsers) {
this.router.navigate(["../"], { relativeTo: this.route }); this.router.navigate(['../'], { relativeTo: this.route });
return; return;
} }
@@ -105,14 +81,17 @@ export class PeopleComponent
await this.load(); await this.load();
this.route.queryParams.pipe(first()).subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
this.searchText = qParams.search; this.searchText = qParams.search;
if (qParams.viewEvents != null) { if (qParams.viewEvents != null) {
const user = this.users.filter((u) => u.id === qParams.viewEvents); const user = this.users.filter(u => u.id === qParams.viewEvents);
if (user.length > 0 && user[0].status === ProviderUserStatusType.Confirmed) { if (user.length > 0 && user[0].status === ProviderUserStatusType.Confirmed) {
this.events(user[0]); this.events(user[0]);
} }
} }
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
}); });
}); });
} }
@@ -138,10 +117,7 @@ export class PeopleComponent
} }
async edit(user: ProviderUserUserDetailsResponse) { async edit(user: ProviderUserUserDetailsResponse) {
const [modal] = await this.modalService.openViewRef( const [modal] = await this.modalService.openViewRef(UserAddEditComponent, this.addEditModalRef, comp => {
UserAddEditComponent,
this.addEditModalRef,
(comp) => {
comp.name = this.userNamePipe.transform(user); comp.name = this.userNamePipe.transform(user);
comp.providerId = this.providerId; comp.providerId = this.providerId;
comp.providerUserId = user != null ? user.id : null; comp.providerUserId = user != null ? user.id : null;
@@ -153,22 +129,17 @@ export class PeopleComponent
modal.close(); modal.close();
this.removeUser(user); this.removeUser(user);
}); });
} });
);
} }
async events(user: ProviderUserUserDetailsResponse) { async events(user: ProviderUserUserDetailsResponse) {
const [modal] = await this.modalService.openViewRef( const [modal] = await this.modalService.openViewRef(EntityEventsComponent, this.eventsModalRef, comp => {
EntityEventsComponent,
this.eventsModalRef,
(comp) => {
comp.name = this.userNamePipe.transform(user); comp.name = this.userNamePipe.transform(user);
comp.providerId = this.providerId; comp.providerId = this.providerId;
comp.entityId = user.id; comp.entityId = user.id;
comp.showUser = false; comp.showUser = false;
comp.entity = "user"; comp.entity = 'user';
} });
);
} }
async bulkRemove() { async bulkRemove() {
@@ -176,14 +147,10 @@ export class PeopleComponent
return; return;
} }
const [modal] = await this.modalService.openViewRef( const [modal] = await this.modalService.openViewRef(BulkRemoveComponent, this.bulkRemoveModalRef, comp => {
BulkRemoveComponent,
this.bulkRemoveModalRef,
(comp) => {
comp.providerId = this.providerId; comp.providerId = this.providerId;
comp.users = this.getCheckedUsers(); comp.users = this.getCheckedUsers();
} });
);
await modal.onClosedPromise(); await modal.onClosedPromise();
await this.load(); await this.load();
@@ -195,26 +162,18 @@ export class PeopleComponent
} }
const users = this.getCheckedUsers(); const users = this.getCheckedUsers();
const filteredUsers = users.filter((u) => u.status === ProviderUserStatusType.Invited); const filteredUsers = users.filter(u => u.status === ProviderUserStatusType.Invited);
if (filteredUsers.length <= 0) { if (filteredUsers.length <= 0) {
this.platformUtilsService.showToast( this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
"error", this.i18nService.t('noSelectedUsersApplicable'));
this.i18nService.t("errorOccurred"),
this.i18nService.t("noSelectedUsersApplicable")
);
return; return;
} }
try { try {
const request = new ProviderUserBulkRequest(filteredUsers.map((user) => user.id)); const request = new ProviderUserBulkRequest(filteredUsers.map(user => user.id));
const response = this.apiService.postManyProviderUserReinvite(this.providerId, request); const response = this.apiService.postManyProviderUserReinvite(this.providerId, request);
this.showBulkStatus( this.showBulkStatus(users, filteredUsers, response, this.i18nService.t('bulkReinviteMessage'));
users,
filteredUsers,
response,
this.i18nService.t("bulkReinviteMessage")
);
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
} }
@@ -226,32 +185,21 @@ export class PeopleComponent
return; return;
} }
const [modal] = await this.modalService.openViewRef( const [modal] = await this.modalService.openViewRef(BulkConfirmComponent, this.bulkConfirmModalRef, comp => {
BulkConfirmComponent,
this.bulkConfirmModalRef,
(comp) => {
comp.providerId = this.providerId; comp.providerId = this.providerId;
comp.users = this.getCheckedUsers(); comp.users = this.getCheckedUsers();
} });
);
await modal.onClosedPromise(); await modal.onClosedPromise();
await this.load(); await this.load();
} }
private async showBulkStatus( private async showBulkStatus(users: ProviderUserUserDetailsResponse[], filteredUsers: ProviderUserUserDetailsResponse[],
users: ProviderUserUserDetailsResponse[], request: Promise<ListResponse<ProviderUserBulkResponse>>, successfullMessage: string) {
filteredUsers: ProviderUserUserDetailsResponse[],
request: Promise<ListResponse<ProviderUserBulkResponse>>, const [modal, childComponent] = await this.modalService.openViewRef(BulkStatusComponent, this.bulkStatusModalRef, comp => {
successfullMessage: string
) {
const [modal, childComponent] = await this.modalService.openViewRef(
BulkStatusComponent,
this.bulkStatusModalRef,
(comp) => {
comp.loading = true; comp.loading = true;
} });
);
// Workaround to handle closing the modal shortly after it has been opened // Workaround to handle closing the modal shortly after it has been opened
let close = false; let close = false;
@@ -265,15 +213,13 @@ export class PeopleComponent
const response = await request; const response = await request;
if (modal) { if (modal) {
const keyedErrors: any = response.data const keyedErrors: any = response.data.filter(r => r.error !== '').reduce((a, x) => ({ ...a, [x.id]: x.error }), {});
.filter((r) => r.error !== "")
.reduce((a, x) => ({ ...a, [x.id]: x.error }), {});
const keyedFilteredUsers: any = filteredUsers.reduce((a, x) => ({ ...a, [x.id]: x }), {}); const keyedFilteredUsers: any = filteredUsers.reduce((a, x) => ({ ...a, [x.id]: x }), {});
childComponent.users = users.map((user) => { childComponent.users = users.map(user => {
let message = keyedErrors[user.id] ?? successfullMessage; let message = keyedErrors[user.id] ?? successfullMessage;
if (!keyedFilteredUsers.hasOwnProperty(user.id)) { if (!keyedFilteredUsers.hasOwnProperty(user.id)) {
message = this.i18nService.t("bulkFilteredMessage"); message = this.i18nService.t('bulkFilteredMessage');
} }
return { return {

View File

@@ -1,121 +1,68 @@
<div class="modal fade" role="dialog" aria-modal="true" aria-labelledby="userAddEditTitle"> <div class="modal fade" tabindex="-1" role="dialog" aria-modal="true" aria-labelledby="userAddEditTitle">
<div class="modal-dialog modal-dialog-scrollable modal-lg" role="document"> <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
<form <form class="modal-content" #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
class="modal-content"
#form
(ngSubmit)="submit()"
[appApiAction]="formPromise"
ngNativeValidate
>
<div class="modal-header"> <div class="modal-header">
<h2 class="modal-title" id="userAddEditTitle"> <h2 class="modal-title" id="userAddEditTitle">
{{ title }} {{title}}
<small class="text-muted" *ngIf="name">{{ name }}</small> <small class="text-muted" *ngIf="name">{{name}}</small>
</h2> </h2>
<button <button type="button" class="close" data-dismiss="modal" appA11yTitle="{{'close' | i18n}}">
type="button"
class="close"
data-dismiss="modal"
appA11yTitle="{{ 'close' | i18n }}"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body" *ngIf="loading"> <div class="modal-body" *ngIf="loading">
<i <i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</div> </div>
<div class="modal-body" *ngIf="!loading"> <div class="modal-body" *ngIf="!loading">
<ng-container *ngIf="!editMode"> <ng-container *ngIf="!editMode">
<p>{{ "providerInviteUserDesc" | i18n }}</p> <p>{{'providerInviteUserDesc' | i18n}}</p>
<div class="form-group mb-4"> <div class="form-group mb-4">
<label for="emails">{{ "email" | i18n }}</label> <label for="emails">{{'email' | i18n}}</label>
<input <input id="emails" class="form-control" type="text" name="Emails" [(ngModel)]="emails" required
id="emails" appAutoFocus>
class="form-control" <small class="text-muted">{{'inviteMultipleEmailDesc' | i18n : '20'}}</small>
type="text"
name="Emails"
[(ngModel)]="emails"
required
appAutoFocus
/>
<small class="text-muted">{{ "inviteMultipleEmailDesc" | i18n: "20" }}</small>
</div> </div>
</ng-container> </ng-container>
<h3> <h3>
{{ "userType" | i18n }} {{'userType' | i18n}}
<a <a target="_blank" rel="noopener" appA11yTitle="{{'learnMore' | i18n}}"
target="_blank" href="https://bitwarden.com/help/article/user-types-access-control/#user-types">
rel="noopener" <i class="fa fa-question-circle-o" aria-hidden="true"></i>
appA11yTitle="{{ 'learnMore' | i18n }}"
href="https://bitwarden.com/help/article/user-types-access-control/#user-types"
>
<i class="bwi bwi-question-circle" aria-hidden="true"></i>
</a> </a>
</h3> </h3>
<div class="form-check mt-2 form-check-block"> <div class="form-check mt-2 form-check-block">
<input <input class="form-check-input" type="radio" name="userType" id="userTypeServiceUser"
class="form-check-input" [value]="userType.ServiceUser" [(ngModel)]="type">
type="radio"
name="userType"
id="userTypeServiceUser"
[value]="userType.ServiceUser"
[(ngModel)]="type"
/>
<label class="form-check-label" for="userTypeServiceUser"> <label class="form-check-label" for="userTypeServiceUser">
{{ "serviceUser" | i18n }} {{'serviceUser' | i18n}}
<small>{{ "serviceUserDesc" | i18n }}</small> <small>{{'serviceUserDesc' | i18n}}</small>
</label> </label>
</div> </div>
<div class="form-check mt-2 form-check-block"> <div class="form-check mt-2 form-check-block">
<input <input class="form-check-input" type="radio" name="userType" id="userTypeProviderAdmin"
class="form-check-input" [value]="userType.ProviderAdmin" [(ngModel)]="type">
type="radio"
name="userType"
id="userTypeProviderAdmin"
[value]="userType.ProviderAdmin"
[(ngModel)]="type"
/>
<label class="form-check-label" for="userTypeProviderAdmin"> <label class="form-check-label" for="userTypeProviderAdmin">
{{ "providerAdmin" | i18n }} {{'providerAdmin' | i18n}}
<small>{{ "providerAdminDesc" | i18n }}</small> <small>{{'providerAdminDesc' | i18n}}</small>
</label> </label>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading"> <button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span>{{ "save" | i18n }}</span> <span>{{'save' | i18n}}</span>
</button> </button>
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal"> <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">
{{ "cancel" | i18n }} {{'cancel' | i18n}}
</button> </button>
<div class="ml-auto"> <div class="ml-auto">
<button <button #deleteBtn type="button" (click)="delete()" class="btn btn-outline-danger"
#deleteBtn appA11yTitle="{{'delete' | i18n}}" *ngIf="editMode" [disabled]="deleteBtn.loading"
type="button" [appApiAction]="deletePromise">
(click)="delete()" <i class="fa fa-trash-o fa-lg fa-fw" [hidden]="deleteBtn.loading" aria-hidden="true"></i>
class="btn btn-outline-danger" <i class="fa fa-spinner fa-spin fa-lg fa-fw" [hidden]="!deleteBtn.loading"
appA11yTitle="{{ 'delete' | i18n }}" title="{{'loading' | i18n}}" aria-hidden="true"></i>
*ngIf="editMode"
[disabled]="deleteBtn.loading"
[appApiAction]="deletePromise"
>
<i
class="bwi bwi-trash bwi-lg bwi-fw"
[hidden]="deleteBtn.loading"
aria-hidden="true"
></i>
<i
class="bwi bwi-spinner bwi-spin bwi-lg bwi-fw"
[hidden]="!deleteBtn.loading"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
</div> </div>
</div> </div>

View File

@@ -1,20 +1,27 @@
import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core"; import {
Component,
EventEmitter,
Input,
OnInit,
Output,
} from '@angular/core';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ToasterService } from 'angular2-toaster';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { ProviderUserInviteRequest } from "jslib-common/models/request/provider/providerUserInviteRequest"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PermissionsApi } from "jslib-common/models/api/permissionsApi"; import { ProviderUserInviteRequest } from 'jslib-common/models/request/provider/providerUserInviteRequest';
import { ProviderUserType } from "jslib-common/enums/providerUserType"; import { PermissionsApi } from 'jslib-common/models/api/permissionsApi';
import { ProviderUserUpdateRequest } from "jslib-common/models/request/provider/providerUserUpdateRequest";
import { ProviderUserType } from 'jslib-common/enums/providerUserType';
import { ProviderUserUpdateRequest } from 'jslib-common/models/request/provider/providerUserUpdateRequest';
@Component({ @Component({
selector: "provider-user-add-edit", selector: 'provider-user-add-edit',
templateUrl: "user-add-edit.component.html", templateUrl: 'user-add-edit.component.html',
}) })
export class UserAddEditComponent implements OnInit { export class UserAddEditComponent implements OnInit {
@Input() name: string; @Input() name: string;
@@ -30,32 +37,26 @@ export class UserAddEditComponent implements OnInit {
type: ProviderUserType = ProviderUserType.ServiceUser; type: ProviderUserType = ProviderUserType.ServiceUser;
permissions = new PermissionsApi(); permissions = new PermissionsApi();
showCustom = false; showCustom = false;
access: "all" | "selected" = "selected"; access: 'all' | 'selected' = 'selected';
formPromise: Promise<any>; formPromise: Promise<any>;
deletePromise: Promise<any>; deletePromise: Promise<any>;
userType = ProviderUserType; userType = ProviderUserType;
constructor( constructor(private apiService: ApiService, private i18nService: I18nService,
private apiService: ApiService, private toasterService: ToasterService, private platformUtilsService: PlatformUtilsService) { }
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private logService: LogService
) {}
async ngOnInit() { async ngOnInit() {
this.editMode = this.loading = this.providerUserId != null; this.editMode = this.loading = this.providerUserId != null;
if (this.editMode) { if (this.editMode) {
this.editMode = true; this.editMode = true;
this.title = this.i18nService.t("editUser"); this.title = this.i18nService.t('editUser');
try { try {
const user = await this.apiService.getProviderUser(this.providerId, this.providerUserId); const user = await this.apiService.getProviderUser(this.providerId, this.providerUserId);
this.type = user.type; this.type = user.type;
} catch (e) { } catch { }
this.logService.error(e);
}
} else { } else {
this.title = this.i18nService.t("inviteUser"); this.title = this.i18nService.t('inviteUser');
} }
this.loading = false; this.loading = false;
@@ -66,11 +67,7 @@ export class UserAddEditComponent implements OnInit {
if (this.editMode) { if (this.editMode) {
const request = new ProviderUserUpdateRequest(); const request = new ProviderUserUpdateRequest();
request.type = this.type; request.type = this.type;
this.formPromise = this.apiService.putProviderUser( this.formPromise = this.apiService.putProviderUser(this.providerId, this.providerUserId, request);
this.providerId,
this.providerUserId,
request
);
} else { } else {
const request = new ProviderUserInviteRequest(); const request = new ProviderUserInviteRequest();
request.emails = this.emails.trim().split(/\s*,\s*/); request.emails = this.emails.trim().split(/\s*,\s*/);
@@ -78,15 +75,10 @@ export class UserAddEditComponent implements OnInit {
this.formPromise = this.apiService.postProviderUserInvite(this.providerId, request); this.formPromise = this.apiService.postProviderUserInvite(this.providerId, request);
} }
await this.formPromise; await this.formPromise;
this.platformUtilsService.showToast( this.toasterService.popAsync('success', null,
"success", this.i18nService.t(this.editMode ? 'editedUserId' : 'invitedUsers', this.name));
null,
this.i18nService.t(this.editMode ? "editedUserId" : "invitedUsers", this.name)
);
this.onSavedUser.emit(); this.onSavedUser.emit();
} catch (e) { } catch { }
this.logService.error(e);
}
} }
async delete() { async delete() {
@@ -95,12 +87,8 @@ export class UserAddEditComponent implements OnInit {
} }
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t("removeUserConfirmation"), this.i18nService.t('removeUserConfirmation'), this.name,
this.name, this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
this.i18nService.t("yes"),
this.i18nService.t("no"),
"warning"
);
if (!confirmed) { if (!confirmed) {
return false; return false;
} }
@@ -108,14 +96,9 @@ export class UserAddEditComponent implements OnInit {
try { try {
this.deletePromise = this.apiService.deleteProviderUser(this.providerId, this.providerUserId); this.deletePromise = this.apiService.deleteProviderUser(this.providerId, this.providerUserId);
await this.deletePromise; await this.deletePromise;
this.platformUtilsService.showToast( this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', this.name));
"success",
null,
this.i18nService.t("removedUserId", this.name)
);
this.onDeletedUser.emit(); this.onDeletedUser.emit();
} catch (e) { } catch { }
this.logService.error(e);
}
} }
} }

View File

@@ -5,33 +5,33 @@
<div class="my-auto d-flex align-items-center pl-1"> <div class="my-auto d-flex align-items-center pl-1">
<app-avatar [data]="provider.name" size="45" [circle]="true"></app-avatar> <app-avatar [data]="provider.name" size="45" [circle]="true"></app-avatar>
<div class="org-name ml-3"> <div class="org-name ml-3">
<span>{{ provider.name }}</span> <span>{{provider.name}}</span>
<small class="text-muted">{{ "provider" | i18n }}</small> <small class="text-muted">{{'provider' | i18n}}</small>
</div> </div>
<div class="ml-3 card border-danger text-danger bg-transparent" *ngIf="!provider.enabled"> <div class="ml-3 card border-danger text-danger bg-transparent" *ngIf="!provider.enabled">
<div class="card-body py-2"> <div class="card-body py-2">
<i class="bwi bwi-exclamation-triangle" aria-hidden="true"></i> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
{{ "providerIsDisabled" | i18n }} {{'providerIsDisabled' | i18n}}
</div> </div>
</div> </div>
</div> </div>
<ul class="nav nav-tabs" *ngIf="showMenuBar"> <ul class="nav nav-tabs" *ngIf="showMenuBar">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" routerLink="clients" routerLinkActive="active"> <a class="nav-link" routerLink="clients" routerLinkActive="active">
<i class="bwi bwi-bank" aria-hidden="true"></i> <i class="fa fa-university" aria-hidden="true"></i>
{{ "clients" | i18n }} {{'clients' | i18n}}
</a> </a>
</li> </li>
<li class="nav-item" *ngIf="showManageTab"> <li class="nav-item" *ngIf="showManageTab">
<a class="nav-link" [routerLink]="manageRoute" routerLinkActive="active"> <a class="nav-link" [routerLink]="manageRoute" routerLinkActive="active">
<i class="bwi bwi-sliders" aria-hidden="true"></i> <i class="fa fa-sliders" aria-hidden="true"></i>
{{ "manage" | i18n }} {{'manage' | i18n}}
</a> </a>
</li> </li>
<li class="nav-item" *ngIf="showSettingsTab"> <li class="nav-item" *ngIf="showSettingsTab">
<a class="nav-link" routerLink="settings" routerLinkActive="active"> <a class="nav-link" routerLink="settings" routerLinkActive="active">
<i class="bwi bwi-cogs" aria-hidden="true"></i> <i class="fa fa-cogs" aria-hidden="true"></i>
{{ "settings" | i18n }} {{'settings' | i18n}}
</a> </a>
</li> </li>
</ul> </ul>

View File

@@ -1,30 +1,31 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from '@angular/router';
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { UserService } from 'jslib-common/abstractions/user.service';
import { Provider } from "jslib-common/models/domain/provider"; import { Provider } from 'jslib-common/models/domain/provider';
@Component({ @Component({
selector: "providers-layout", selector: 'providers-layout',
templateUrl: "providers-layout.component.html", templateUrl: 'providers-layout.component.html',
}) })
export class ProvidersLayoutComponent { export class ProvidersLayoutComponent {
provider: Provider; provider: Provider;
private providerId: string; private providerId: string;
constructor(private route: ActivatedRoute, private providerService: ProviderService) {} constructor(private route: ActivatedRoute, private userService: UserService) { }
ngOnInit() { ngOnInit() {
document.body.classList.remove("layout_frontend"); document.body.classList.remove('layout_frontend');
this.route.params.subscribe(async (params) => { this.route.params.subscribe(async params => {
this.providerId = params.providerId; this.providerId = params.providerId;
await this.load(); await this.load();
}); });
} }
async load() { async load() {
this.provider = await this.providerService.get(this.providerId); this.provider = await this.userService.getProvider(this.providerId);
} }
get showMenuBar() { get showMenuBar() {
@@ -42,9 +43,9 @@ export class ProvidersLayoutComponent {
get manageRoute(): string { get manageRoute(): string {
switch (true) { switch (true) {
case this.provider.canManageUsers: case this.provider.canManageUsers:
return "manage/people"; return 'manage/people';
case this.provider.canAccessEventLogs: case this.provider.canAccessEventLogs:
return "manage/events"; return 'manage/events';
} }
} }
} }

View File

@@ -1,110 +1,110 @@
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from "@angular/router"; import { RouterModule, Routes } from '@angular/router';
import { AuthGuardService } from "jslib-angular/services/auth-guard.service"; import { AuthGuardService } from 'jslib-angular/services/auth-guard.service';
import { Permissions } from "jslib-common/enums/permissions"; import { Permissions } from 'jslib-common/enums/permissions';
import { AddOrganizationComponent } from "./clients/add-organization.component"; import { AddOrganizationComponent } from './clients/add-organization.component';
import { ClientsComponent } from "./clients/clients.component"; import { ClientsComponent } from './clients/clients.component';
import { CreateOrganizationComponent } from "./clients/create-organization.component"; import { CreateOrganizationComponent } from './clients/create-organization.component';
import { AcceptProviderComponent } from "./manage/accept-provider.component"; import { AcceptProviderComponent } from './manage/accept-provider.component';
import { EventsComponent } from "./manage/events.component"; import { EventsComponent } from './manage/events.component';
import { ManageComponent } from "./manage/manage.component"; import { ManageComponent } from './manage/manage.component';
import { PeopleComponent } from "./manage/people.component"; import { PeopleComponent } from './manage/people.component';
import { ProvidersLayoutComponent } from "./providers-layout.component"; import { ProvidersLayoutComponent } from './providers-layout.component';
import { SettingsComponent } from "./settings/settings.component"; import { SettingsComponent } from './settings/settings.component';
import { SetupProviderComponent } from "./setup/setup-provider.component"; import { SetupProviderComponent } from './setup/setup-provider.component';
import { SetupComponent } from "./setup/setup.component"; import { SetupComponent } from './setup/setup.component';
import { FrontendLayoutComponent } from "src/app/layouts/frontend-layout.component"; import { FrontendLayoutComponent } from 'src/app/layouts/frontend-layout.component';
import { ProvidersComponent } from "src/app/providers/providers.component"; import { ProvidersComponent } from 'src/app/providers/providers.component';
import { ProviderGuardService } from "./services/provider-guard.service"; import { ProviderGuardService } from './services/provider-guard.service';
import { ProviderTypeGuardService } from "./services/provider-type-guard.service"; import { ProviderTypeGuardService } from './services/provider-type-guard.service';
import { AccountComponent } from "./settings/account.component"; import { AccountComponent } from './settings/account.component';
const routes: Routes = [ const routes: Routes = [
{ {
path: "", path: '',
canActivate: [AuthGuardService], canActivate: [AuthGuardService],
component: ProvidersComponent, component: ProvidersComponent,
}, },
{ {
path: "", path: '',
component: FrontendLayoutComponent, component: FrontendLayoutComponent,
children: [ children: [
{ {
path: "setup-provider", path: 'setup-provider',
component: SetupProviderComponent, component: SetupProviderComponent,
data: { titleId: "setupProvider" }, data: { titleId: 'setupProvider' },
}, },
{ {
path: "accept-provider", path: 'accept-provider',
component: AcceptProviderComponent, component: AcceptProviderComponent,
data: { titleId: "acceptProvider" }, data: { titleId: 'acceptProvider' },
}, },
], ],
}, },
{ {
path: "", path: '',
canActivate: [AuthGuardService], canActivate: [AuthGuardService],
children: [ children: [
{ {
path: "setup", path: 'setup',
component: SetupComponent, component: SetupComponent,
}, },
{ {
path: ":providerId", path: ':providerId',
component: ProvidersLayoutComponent, component: ProvidersLayoutComponent,
canActivate: [ProviderGuardService], canActivate: [ProviderGuardService],
children: [ children: [
{ path: "", pathMatch: "full", redirectTo: "clients" }, { path: '', pathMatch: 'full', redirectTo: 'clients' },
{ path: "clients/create", component: CreateOrganizationComponent }, { path: 'clients/create', component: CreateOrganizationComponent },
{ path: "clients", component: ClientsComponent, data: { titleId: "clients" } }, { path: 'clients', component: ClientsComponent, data: { titleId: 'clients' } },
{ {
path: "manage", path: 'manage',
component: ManageComponent, component: ManageComponent,
children: [ children: [
{ {
path: "", path: '',
pathMatch: "full", pathMatch: 'full',
redirectTo: "people", redirectTo: 'people',
}, },
{ {
path: "people", path: 'people',
component: PeopleComponent, component: PeopleComponent,
canActivate: [ProviderTypeGuardService], canActivate: [ProviderTypeGuardService],
data: { data: {
titleId: "people", titleId: 'people',
permissions: [Permissions.ManageUsers], permissions: [Permissions.ManageUsers],
}, },
}, },
{ {
path: "events", path: 'events',
component: EventsComponent, component: EventsComponent,
canActivate: [ProviderTypeGuardService], canActivate: [ProviderTypeGuardService],
data: { data: {
titleId: "eventLogs", titleId: 'eventLogs',
permissions: [Permissions.AccessEventLogs], permissions: [Permissions.AccessEventLogs],
}, },
}, },
], ],
}, },
{ {
path: "settings", path: 'settings',
component: SettingsComponent, component: SettingsComponent,
children: [ children: [
{ {
path: "", path: '',
pathMatch: "full", pathMatch: 'full',
redirectTo: "account", redirectTo: 'account',
}, },
{ {
path: "account", path: 'account',
component: AccountComponent, component: AccountComponent,
canActivate: [ProviderTypeGuardService], canActivate: [ProviderTypeGuardService],
data: { data: {
titleId: "myProvider", titleId: 'myProvider',
permissions: [Permissions.ManageProvider], permissions: [Permissions.ManageProvider],
}, },
}, },
@@ -120,4 +120,4 @@ const routes: Routes = [
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule], exports: [RouterModule],
}) })
export class ProvidersRoutingModule {} export class ProvidersRoutingModule { }

View File

@@ -1,39 +1,44 @@
import { CommonModule } from "@angular/common"; import { CommonModule } from '@angular/common';
import { ComponentFactoryResolver } from "@angular/core"; import { ComponentFactoryResolver } from '@angular/core';
import { NgModule } from "@angular/core"; import { NgModule } from '@angular/core';
import { FormsModule } from "@angular/forms"; import { FormsModule } from '@angular/forms';
import { ModalService } from "jslib-angular/services/modal.service"; import { ModalService } from 'jslib-angular/services/modal.service';
import { ProviderGuardService } from "./services/provider-guard.service"; import { ProviderGuardService } from './services/provider-guard.service';
import { ProviderTypeGuardService } from "./services/provider-type-guard.service"; import { ProviderTypeGuardService } from './services/provider-type-guard.service';
import { WebProviderService } from "./services/webProvider.service"; import { ProviderService } from './services/provider.service';
import { ProvidersLayoutComponent } from "./providers-layout.component"; import { ProvidersLayoutComponent } from './providers-layout.component';
import { ProvidersRoutingModule } from "./providers-routing.module"; import { ProvidersRoutingModule } from './providers-routing.module';
import { AddOrganizationComponent } from "./clients/add-organization.component"; import { AddOrganizationComponent } from './clients/add-organization.component';
import { ClientsComponent } from "./clients/clients.component"; import { ClientsComponent } from './clients/clients.component';
import { CreateOrganizationComponent } from "./clients/create-organization.component"; import { CreateOrganizationComponent } from './clients/create-organization.component';
import { AcceptProviderComponent } from "./manage/accept-provider.component"; import { AcceptProviderComponent } from './manage/accept-provider.component';
import { BulkConfirmComponent } from "./manage/bulk/bulk-confirm.component"; import { BulkConfirmComponent } from './manage/bulk/bulk-confirm.component';
import { BulkRemoveComponent } from "./manage/bulk/bulk-remove.component"; import { BulkRemoveComponent } from './manage/bulk/bulk-remove.component';
import { EventsComponent } from "./manage/events.component"; import { EventsComponent } from './manage/events.component';
import { ManageComponent } from "./manage/manage.component"; import { ManageComponent } from './manage/manage.component';
import { PeopleComponent } from "./manage/people.component"; import { PeopleComponent } from './manage/people.component';
import { UserAddEditComponent } from "./manage/user-add-edit.component"; import { UserAddEditComponent } from './manage/user-add-edit.component';
import { AccountComponent } from "./settings/account.component"; import { AccountComponent } from './settings/account.component';
import { SettingsComponent } from "./settings/settings.component"; import { SettingsComponent } from './settings/settings.component';
import { SetupProviderComponent } from "./setup/setup-provider.component"; import { SetupProviderComponent } from './setup/setup-provider.component';
import { SetupComponent } from "./setup/setup.component"; import { SetupComponent } from './setup/setup.component';
import { OssModule } from "src/app/oss.module"; import { OssModule } from 'src/app/oss.module';
@NgModule({ @NgModule({
imports: [CommonModule, FormsModule, OssModule, ProvidersRoutingModule], imports: [
CommonModule,
FormsModule,
OssModule,
ProvidersRoutingModule,
],
declarations: [ declarations: [
AcceptProviderComponent, AcceptProviderComponent,
AccountComponent, AccountComponent,
@@ -51,13 +56,14 @@ import { OssModule } from "src/app/oss.module";
SetupProviderComponent, SetupProviderComponent,
UserAddEditComponent, UserAddEditComponent,
], ],
providers: [WebProviderService, ProviderGuardService, ProviderTypeGuardService], providers: [
ProviderService,
ProviderGuardService,
ProviderTypeGuardService,
],
}) })
export class ProvidersModule { export class ProvidersModule {
constructor(modalService: ModalService, componentFactoryResolver: ComponentFactoryResolver) { constructor(modalService: ModalService, componentFactoryResolver: ComponentFactoryResolver) {
modalService.registerComponentFactoryResolver( modalService.registerComponentFactoryResolver(AddOrganizationComponent, componentFactoryResolver);
AddOrganizationComponent,
componentFactoryResolver
);
} }
} }

View File

@@ -1,28 +1,29 @@
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router } from "@angular/router"; import {
ActivatedRouteSnapshot,
CanActivate,
Router,
} from '@angular/router';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { ToasterService } from 'angular2-toaster';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { UserService } from 'jslib-common/abstractions/user.service';
@Injectable() @Injectable()
export class ProviderGuardService implements CanActivate { export class ProviderGuardService implements CanActivate {
constructor( constructor(private userService: UserService, private router: Router,
private router: Router, private toasterService: ToasterService, private i18nService: I18nService) { }
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private providerService: ProviderService
) {}
async canActivate(route: ActivatedRouteSnapshot) { async canActivate(route: ActivatedRouteSnapshot) {
const provider = await this.providerService.get(route.params.providerId); const provider = await this.userService.getProvider(route.params.providerId);
if (provider == null) { if (provider == null) {
this.router.navigate(["/"]); this.router.navigate(['/']);
return false; return false;
} }
if (!provider.isProviderAdmin && !provider.enabled) { if (!provider.isProviderAdmin && !provider.enabled) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("providerIsDisabled")); this.toasterService.popAsync('error', null, this.i18nService.t('providerIsDisabled'));
this.router.navigate(["/"]); this.router.navigate(['/']);
return false; return false;
} }

View File

@@ -1,17 +1,21 @@
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router } from "@angular/router"; import {
ActivatedRouteSnapshot,
CanActivate,
Router,
} from '@angular/router';
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { UserService } from 'jslib-common/abstractions/user.service';
import { Permissions } from "jslib-common/enums/permissions"; import { Permissions } from 'jslib-common/enums/permissions';
@Injectable() @Injectable()
export class ProviderTypeGuardService implements CanActivate { export class ProviderTypeGuardService implements CanActivate {
constructor(private providerService: ProviderService, private router: Router) {} constructor(private userService: UserService, private router: Router) { }
async canActivate(route: ActivatedRouteSnapshot) { async canActivate(route: ActivatedRouteSnapshot) {
const provider = await this.providerService.get(route.params.providerId); const provider = await this.userService.getProvider(route.params.providerId);
const permissions = route.data == null ? null : (route.data.permissions as Permissions[]); const permissions = route.data == null ? null : route.data.permissions as Permissions[];
if ( if (
(permissions.indexOf(Permissions.AccessEventLogs) !== -1 && provider.canAccessEventLogs) || (permissions.indexOf(Permissions.AccessEventLogs) !== -1 && provider.canAccessEventLogs) ||
@@ -21,7 +25,7 @@ export class ProviderTypeGuardService implements CanActivate {
return true; return true;
} }
this.router.navigate(["/providers", provider.id]); this.router.navigate(['/providers', provider.id]);
return false; return false;
} }
} }

View File

@@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { ProviderAddOrganizationRequest } from 'jslib-common/models/request/provider/providerAddOrganizationRequest';
@Injectable()
export class ProviderService {
constructor(private cryptoService: CryptoService, private syncService: SyncService, private apiService: ApiService) {}
async addOrganizationToProvider(providerId: string, organizationId: string) {
const orgKey = await this.cryptoService.getOrgKey(organizationId);
const providerKey = await this.cryptoService.getProviderKey(providerId);
const encryptedOrgKey = await this.cryptoService.encrypt(orgKey.key, providerKey);
const request = new ProviderAddOrganizationRequest();
request.organizationId = organizationId;
request.key = encryptedOrgKey.encryptedString;
const response = await this.apiService.postProviderAddOrganization(providerId, request);
await this.syncService.fullSync(true);
return response;
}
async detachOrganizastion(providerId: string, organizationId: string): Promise<any> {
await this.apiService.deleteProviderOrganization(providerId, organizationId);
await this.syncService.fullSync(true);
}
}

View File

@@ -1,36 +0,0 @@
import { Injectable } from "@angular/core";
import { ApiService } from "jslib-common/abstractions/api.service";
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { SyncService } from "jslib-common/abstractions/sync.service";
import { ProviderAddOrganizationRequest } from "jslib-common/models/request/provider/providerAddOrganizationRequest";
@Injectable()
export class WebProviderService {
constructor(
private cryptoService: CryptoService,
private syncService: SyncService,
private apiService: ApiService
) {}
async addOrganizationToProvider(providerId: string, organizationId: string) {
const orgKey = await this.cryptoService.getOrgKey(organizationId);
const providerKey = await this.cryptoService.getProviderKey(providerId);
const encryptedOrgKey = await this.cryptoService.encrypt(orgKey.key, providerKey);
const request = new ProviderAddOrganizationRequest();
request.organizationId = organizationId;
request.key = encryptedOrgKey.encryptedString;
const response = await this.apiService.postProviderAddOrganization(providerId, request);
await this.syncService.fullSync(true);
return response;
}
async detachOrganizastion(providerId: string, organizationId: string): Promise<any> {
await this.apiService.deleteProviderOrganization(providerId, organizationId);
await this.syncService.fullSync(true);
}
}

View File

@@ -1,52 +1,30 @@
<div class="page-header"> <div class="page-header">
<h1>{{ "myProvider" | i18n }}</h1> <h1>{{'myProvider' | i18n}}</h1>
</div> </div>
<div *ngIf="loading"> <div *ngIf="loading">
<i <i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</div> </div>
<form <form *ngIf="provider && !loading" #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
*ngIf="provider && !loading"
#form
(ngSubmit)="submit()"
[appApiAction]="formPromise"
ngNativeValidate
>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<div class="form-group"> <div class="form-group">
<label for="name">{{ "providerName" | i18n }}</label> <label for="name">{{'providerName' | i18n}}</label>
<input <input id="name" class="form-control" type="text" name="Name" [(ngModel)]="provider.name"
id="name" [disabled]="selfHosted">
class="form-control"
type="text"
name="Name"
[(ngModel)]="provider.name"
[disabled]="selfHosted"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="billingEmail">{{ "billingEmail" | i18n }}</label> <label for="billingEmail">{{'billingEmail' | i18n}}</label>
<input <input id="billingEmail" class="form-control" type="text" name="BillingEmail"
id="billingEmail" [(ngModel)]="provider.billingEmail" [disabled]="selfHosted">
class="form-control"
type="text"
name="BillingEmail"
[(ngModel)]="provider.billingEmail"
[disabled]="selfHosted"
/>
</div> </div>
</div> </div>
<div class="col-6"> <div class="col-6">
<app-avatar data="{{ provider.name }}" dynamic="true" size="75" fontSize="35"></app-avatar> <app-avatar data="{{provider.name}}" 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" class="btn btn-primary btn-submit" [disabled]="form.loading">
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span>{{ "save" | i18n }}</span> <span>{{'save' | i18n}}</span>
</button> </button>
</form> </form>

View File

@@ -1,19 +1,20 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from '@angular/router';
import { ToasterService } from 'angular2-toaster';
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 { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from "jslib-common/abstractions/log.service"; import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SyncService } from "jslib-common/abstractions/sync.service"; import { SyncService } from 'jslib-common/abstractions/sync.service';
import { ProviderUpdateRequest } from "jslib-common/models/request/provider/providerUpdateRequest"; import { ProviderUpdateRequest } from 'jslib-common/models/request/provider/providerUpdateRequest';
import { ProviderResponse } from "jslib-common/models/response/provider/providerResponse"; import { ProviderResponse } from 'jslib-common/models/response/provider/providerResponse';
@Component({ @Component({
selector: "provider-account", selector: 'provider-account',
templateUrl: "account.component.html", templateUrl: 'account.component.html',
}) })
export class AccountComponent { export class AccountComponent {
selfHosted = false; selfHosted = false;
@@ -24,18 +25,14 @@ export class AccountComponent {
private providerId: string; private providerId: string;
constructor( constructor(private apiService: ApiService, private i18nService: I18nService,
private apiService: ApiService, private toasterService: ToasterService, private route: ActivatedRoute,
private i18nService: I18nService, private syncService: SyncService, private platformUtilsService: PlatformUtilsService,
private route: ActivatedRoute, private logService: LogService) { }
private syncService: SyncService,
private platformUtilsService: PlatformUtilsService,
private logService: LogService
) {}
async ngOnInit() { async ngOnInit() {
this.selfHosted = this.platformUtilsService.isSelfHost(); this.selfHosted = this.platformUtilsService.isSelfHost();
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async params => {
this.providerId = params.providerId; this.providerId = params.providerId;
try { try {
this.provider = await this.apiService.getProvider(this.providerId); this.provider = await this.apiService.getProvider(this.providerId);
@@ -57,7 +54,7 @@ export class AccountComponent {
return this.syncService.fullSync(true); return this.syncService.fullSync(true);
}); });
await this.formPromise; await this.formPromise;
this.platformUtilsService.showToast("success", null, this.i18nService.t("providerUpdated")); this.toasterService.popAsync('success', null, this.i18nService.t('providerUpdated'));
} catch (e) { } catch (e) {
this.logService.error(`Handled exception: ${e}`); this.logService.error(`Handled exception: ${e}`);
} }

View File

@@ -2,10 +2,10 @@
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
<div class="card"> <div class="card">
<div class="card-header">{{ "settings" | i18n }}</div> <div class="card-header">{{'settings' | i18n}}</div>
<div class="list-group list-group-flush"> <div class="list-group list-group-flush">
<a routerLink="account" class="list-group-item" routerLinkActive="active"> <a routerLink="account" class="list-group-item" routerLinkActive="active">
{{ "myProvider" | i18n }} {{'myProvider' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,23 +1,20 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from '@angular/router';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ProviderService } from "jslib-common/abstractions/provider.service"; import { UserService } from 'jslib-common/abstractions/user.service';
@Component({ @Component({
selector: "provider-settings", selector: 'provider-settings',
templateUrl: "settings.component.html", templateUrl: 'settings.component.html',
}) })
export class SettingsComponent { export class SettingsComponent {
constructor( constructor(private route: ActivatedRoute, private userService: UserService,
private route: ActivatedRoute, private platformUtilsService: PlatformUtilsService) { }
private providerService: ProviderService,
private platformUtilsService: PlatformUtilsService
) {}
ngOnInit() { ngOnInit() {
this.route.parent.params.subscribe(async (params) => { this.route.parent.params.subscribe(async params => {
const provider = await this.providerService.get(params.providerId); const provider = await this.userService.getProvider(params.providerId);
}); });
} }
} }

View File

@@ -1,27 +1,23 @@
<div class="mt-5 d-flex justify-content-center" *ngIf="loading"> <div class="mt-5 d-flex justify-content-center" *ngIf="loading">
<div> <div>
<img class="mb-4 logo logo-themed" alt="Bitwarden" /> <img class="mb-4 logo logo-themed" alt="Bitwarden">
<p class="text-center"> <p class="text-center">
<i <i class="fa fa-spinner fa-spin fa-2x text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin bwi-2x text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</p> </p>
</div> </div>
</div> </div>
<div class="container" *ngIf="!loading && !authed"> <div class="container" *ngIf="!loading && !authed">
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "setupProvider" | i18n }}</p> <p class="lead text-center mb-4">{{'setupProvider' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<p>{{ "setupProviderLoginDesc" | i18n }}</p> <p>{{'setupProviderLoginDesc' | i18n}}</p>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<a routerLink="/" [queryParams]="{ email: email }" class="btn btn-primary btn-block"> <a routerLink="/" [queryParams]="{email: email}" class="btn btn-primary btn-block">
{{ "logIn" | i18n }} {{'logIn' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,19 +1,20 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { BaseAcceptComponent } from "src/app/common/base.accept.component"; import { BaseAcceptComponent } from 'src/app/common/base.accept.component';
@Component({ @Component({
selector: "app-setup-provider", selector: 'app-setup-provider',
templateUrl: "setup-provider.component.html", templateUrl: 'setup-provider.component.html',
}) })
export class SetupProviderComponent extends BaseAcceptComponent { export class SetupProviderComponent extends BaseAcceptComponent {
failedShortMessage = "inviteAcceptFailedShort";
failedMessage = "inviteAcceptFailed";
requiredParameters = ["providerId", "email", "token"]; failedShortMessage = 'inviteAcceptFailedShort';
failedMessage = 'inviteAcceptFailed';
requiredParameters = ['providerId', 'email', 'token'];
async authedHandler(qParams: any) { async authedHandler(qParams: any) {
this.router.navigate(["/providers/setup"], { queryParams: qParams }); this.router.navigate(['/providers/setup'], {queryParams: qParams});
} }
// tslint:disable-next-line // tslint:disable-next-line

View File

@@ -1,37 +1,30 @@
<app-navbar></app-navbar> <app-navbar></app-navbar>
<div class="container page-content"> <div class="container page-content">
<div class="page-header"> <div class="page-header">
<h1>{{ "setupProvider" | i18n }}</h1> <h1>{{'setupProvider' | i18n}}</h1>
</div> </div>
<p>{{ "setupProviderDesc" | i18n }}</p> <p>{{'setupProviderDesc' | i18n}}</p>
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="loading"> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="loading">
<h2 class="mt-5">{{ "generalInformation" | i18n }}</h2> <h2 class="mt-5">{{'generalInformation' | i18n}}</h2>
<div class="row"> <div class="row">
<div class="form-group col-6"> <div class="form-group col-6">
<label for="name">{{ "providerName" | i18n }}</label> <label for="name">{{'providerName' | i18n}}</label>
<input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name" required /> <input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name" required>
</div> </div>
<div class="form-group col-6"> <div class="form-group col-6">
<label for="billingEmail">{{ "billingEmail" | i18n }}</label> <label for="billingEmail">{{'billingEmail' | i18n}}</label>
<input <input id="billingEmail" class="form-control" type="text" name="BillingEmail" [(ngModel)]="billingEmail" required>
id="billingEmail"
class="form-control"
type="text"
name="BillingEmail"
[(ngModel)]="billingEmail"
required
/>
</div> </div>
</div> </div>
<div class="mt-4"> <div class="mt-4">
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading"> <button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span>{{ "submit" | i18n }}</span> <span>{{'submit' | i18n}}</span>
</button> </button>
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" *ngIf="showCancel"> <button type="button" class="btn btn-outline-secondary" (click)="cancel()" *ngIf="showCancel">
{{ "cancel" | i18n }} {{'cancel' | i18n}}
</button> </button>
</div> </div>
</form> </form>

View File

@@ -1,20 +1,27 @@
import { Component, OnInit } from "@angular/core"; import {
import { ActivatedRoute, Router } from "@angular/router"; Component,
OnInit,
} from '@angular/core';
import {
ActivatedRoute,
Router,
} from '@angular/router';
import {
Toast,
ToasterService,
} from 'angular2-toaster';
import { first } from "rxjs/operators"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ValidationService } from 'jslib-angular/services/validation.service';
import { CryptoService } from "jslib-common/abstractions/crypto.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { ValidationService } from "jslib-angular/services/validation.service"; import { ProviderSetupRequest } from 'jslib-common/models/request/provider/providerSetupRequest';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { SyncService } from "jslib-common/abstractions/sync.service";
import { ProviderSetupRequest } from "jslib-common/models/request/provider/providerSetupRequest";
@Component({ @Component({
selector: "provider-setup", selector: 'provider-setup',
templateUrl: "setup.component.html", templateUrl: 'setup.component.html',
}) })
export class SetupComponent implements OnInit { export class SetupComponent implements OnInit {
loading = true; loading = true;
@@ -27,30 +34,30 @@ export class SetupComponent implements OnInit {
name: string; name: string;
billingEmail: string; billingEmail: string;
constructor( constructor(private router: Router, private toasterService: ToasterService,
private router: Router, private i18nService: I18nService, private route: ActivatedRoute,
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService, private apiService: ApiService,
private i18nService: I18nService, private syncService: SyncService, private validationService: ValidationService) { }
private route: ActivatedRoute,
private cryptoService: CryptoService,
private apiService: ApiService,
private syncService: SyncService,
private validationService: ValidationService
) {}
ngOnInit() { ngOnInit() {
document.body.classList.remove("layout_frontend"); document.body.classList.remove('layout_frontend');
this.route.queryParams.pipe(first()).subscribe(async (qParams) => { let fired = false;
this.route.queryParams.subscribe(async qParams => {
if (fired) {
return;
}
fired = true;
const error = qParams.providerId == null || qParams.email == null || qParams.token == null; const error = qParams.providerId == null || qParams.email == null || qParams.token == null;
if (error) { if (error) {
this.platformUtilsService.showToast( const toast: Toast = {
"error", type: 'error',
null, title: null,
this.i18nService.t("emergencyInviteAcceptFailed"), body: this.i18nService.t('emergencyInviteAcceptFailed'),
{ timeout: 10000 } timeout: 10000,
); };
this.router.navigate(["/"]); this.toasterService.popAsync(toast);
this.router.navigate(['/']);
return; return;
} }
@@ -61,11 +68,11 @@ export class SetupComponent implements OnInit {
try { try {
const provider = await this.apiService.getProvider(this.providerId); const provider = await this.apiService.getProvider(this.providerId);
if (provider.name != null) { if (provider.name != null) {
this.router.navigate(["/providers", provider.id], { replaceUrl: true }); this.router.navigate(['/providers', provider.id], { replaceUrl: true });
} }
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
this.router.navigate(["/"]); this.router.navigate(['/']);
} }
}); });
} }
@@ -88,10 +95,10 @@ export class SetupComponent implements OnInit {
request.key = key; request.key = key;
const provider = await this.apiService.postProviderSetup(this.providerId, request); const provider = await this.apiService.postProviderSetup(this.providerId, request);
this.platformUtilsService.showToast("success", null, this.i18nService.t("providerSetup")); this.toasterService.popAsync('success', null, this.i18nService.t('providerSetup'));
await this.syncService.fullSync(true); await this.syncService.fullSync(true);
this.router.navigate(["/providers", provider.id]); this.router.navigate(['/providers', provider.id]);
} catch (e) { } catch (e) {
this.validationService.showError(e); this.validationService.showError(e);
} }

View File

@@ -1,11 +1,11 @@
const { AngularWebpackPlugin } = require("@ngtools/webpack"); const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
const webpackConfig = require("../webpack.config"); const webpackConfig = require('../webpack.config');
webpackConfig.entry["app/main"] = "./bitwarden_license/src/app/main.ts"; webpackConfig.entry['app/main'] = './bitwarden_license/src/app/main.ts';
webpackConfig.plugins[webpackConfig.plugins.length - 1] = new AngularWebpackPlugin({ webpackConfig.plugins[webpackConfig.plugins.length -1] = new AngularCompilerPlugin({
tsConfigPath: "tsconfig.json", tsConfigPath: 'tsconfig.json',
entryModule: "bitwarden_license/src/app/app.module#AppModule", entryModule: 'bitwarden_license/src/app/app.module#AppModule',
sourceMap: true, sourceMap: true,
}); });

View File

@@ -1,13 +1,8 @@
function load(envName) { function load(envName) {
return { return {
...require("./config/base.json"), ...require('./config/base.json'),
...loadConfig(envName), ...loadConfig(envName),
...loadConfig("local"), ...loadConfig('local'),
dev: {
...require("./config/base.json").dev,
...loadConfig(envName).dev,
...loadConfig("local").dev,
},
}; };
} }
@@ -24,7 +19,8 @@ function loadConfig(configName) {
} catch (e) { } catch (e) {
if (e instanceof Error && e.code === "MODULE_NOT_FOUND") { if (e instanceof Error && e.code === "MODULE_NOT_FOUND") {
return {}; return {};
} else { }
else {
throw e; throw e;
} }
} }
@@ -32,5 +28,5 @@ function loadConfig(configName) {
module.exports = { module.exports = {
load, load,
log, log
}; };

View File

@@ -5,8 +5,5 @@
"paypal": { "paypal": {
"businessId": "AD3LAUZSNVPJY", "businessId": "AD3LAUZSNVPJY",
"buttonAction": "https://www.sandbox.paypal.com/cgi-bin/webscr" "buttonAction": "https://www.sandbox.paypal.com/cgi-bin/webscr"
},
"dev": {
"allowedHosts": "auto"
} }
} }

View File

@@ -8,10 +8,5 @@
"paypal": { "paypal": {
"businessId": "4ZDA7DLUUJGMN", "businessId": "4ZDA7DLUUJGMN",
"buttonAction": "https://www.paypal.com/cgi-bin/webscr" "buttonAction": "https://www.paypal.com/cgi-bin/webscr"
},
"dev": {
"proxyApi": "https://api.bitwarden.com",
"proxyIdentity": "https://identity.bitwarden.com",
"proxyEvents": "https://events.bitwarden.com"
} }
} }

View File

@@ -1,11 +1,10 @@
{ {
"urls": {
"notifications": "http://localhost:61840"
},
"dev": {
"proxyApi": "http://localhost:4000", "proxyApi": "http://localhost:4000",
"proxyIdentity": "http://localhost:33656", "proxyIdentity": "http://localhost:33656",
"proxyEvents": "http://localhost:46273", "proxyEvents": "http://localhost:46273",
"proxyNotifications": "http://localhost:61840" "proxyNotifications": "http://localhost:61840",
"allowedHosts": [],
"urls": {
"notifications": "http://localhost:61840"
} }
} }

View File

@@ -2,10 +2,5 @@
"urls": { "urls": {
"icons": "https://icons.qa.bitwarden.pw", "icons": "https://icons.qa.bitwarden.pw",
"notifications": "https://notifications.qa.bitwarden.pw" "notifications": "https://notifications.qa.bitwarden.pw"
},
"dev": {
"proxyApi": "https://api.qa.bitwarden.pw",
"proxyIdentity": "https://identity.qa.bitwarden.pw",
"proxyEvents": "https://events.qa.bitwarden.pw"
} }
} }

View File

@@ -1,9 +1,7 @@
project_id_env: _CROWDIN_PROJECT_ID project_id_env: _CROWDIN_PROJECT_ID
api_token_env: CROWDIN_API_TOKEN api_token_env: CROWDIN_API_TOKEN
preserve_hierarchy: true
files: files:
- source: /src/locales/en/messages.json - source: /src/locales/en/messages.json
dest: /src/locales/en/%file_name%.%file_extension%
translation: /src/locales/%two_letters_code%/%original_file_name% translation: /src/locales/%two_letters_code%/%original_file_name%
update_option: update_as_unapproved update_option: update_as_unapproved
languages_mapping: languages_mapping:

View File

@@ -1,138 +0,0 @@
types {
# Data interchange
application/atom+xml atom;
application/json json map topojson;
application/ld+json jsonld;
application/rss+xml rss;
application/vnd.geo+json geojson;
application/xml rdf xml;
# JavaScript
# Normalize to standard type.
# https://tools.ietf.org/html/rfc4329#section-7.2
application/javascript js;
# Manifest files
application/manifest+json webmanifest;
application/x-web-app-manifest+json webapp;
text/cache-manifest appcache;
# Media files
audio/midi mid midi kar;
audio/mp4 aac f4a f4b m4a;
audio/mpeg mp3;
audio/ogg oga ogg opus;
audio/x-realaudio ra;
audio/x-wav wav;
image/bmp bmp;
image/gif gif;
image/jpeg jpeg jpg;
image/jxr jxr hdp wdp;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-jng jng;
video/3gpp 3gp 3gpp;
video/mp4 f4p f4v m4v mp4;
video/mpeg mpeg mpg;
video/ogg ogv;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asf asx;
video/x-ms-wmv wmv;
video/x-msvideo avi;
# Serving `.ico` image files with a different media type
# prevents Internet Explorer from displaying then as images:
# https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee
image/x-icon cur ico;
# Microsoft Office
application/msword doc;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
# Web fonts
application/font-woff woff;
application/font-woff2 woff2;
application/vnd.ms-fontobject eot;
# Browsers usually ignore the font media types and simply sniff
# the bytes to figure out the font type.
# https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
#
# However, Blink and WebKit based browsers will show a warning
# in the console if the following font types are served with any
# other media types.
application/x-font-ttf ttc ttf;
font/opentype otf;
# Other
application/java-archive ear jar war;
application/mac-binhex40 hqx;
application/octet-stream bin deb dll dmg exe img iso msi msm msp safariextz;
application/pdf pdf;
application/postscript ai eps ps;
application/rtf rtf;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.wap.wmlc wmlc;
application/x-7z-compressed 7z;
application/x-bb-appworld bbaw;
application/x-bittorrent torrent;
application/x-chrome-extension crx;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-opera-extension oex;
application/x-perl pl pm;
application/x-pilot pdb prc;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert crt der pem;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xslt+xml xsl;
application/zip zip;
text/css css;
text/csv csv;
text/html htm html shtml;
text/markdown md;
text/mathml mml;
text/plain txt;
text/vcard vcard vcf;
text/vnd.rim.location.xloc xloc;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/vtt vtt;
text/x-component htc;
}

View File

@@ -1,25 +0,0 @@
#######################################################################
# WARNING: This file is generated. Do not make changes to this file. #
# They will be overwritten on update. You can manage various settings #
# used in this file from the ./bwdata/config.yml file for your #
# installation. #
#######################################################################
server {
listen 8080 default_server;
listen [::]:8080 default_server;
include /etc/nginx/security-headers.conf;
location / {
root /app;
index index.html index.htm;
include /etc/nginx/security-headers.conf;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Robots-Tag "noindex, nofollow";
}
location /alive {
return 200 'alive';
add_header Content-Type text/plain;
}
}

View File

@@ -1,147 +0,0 @@
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
# user www www;
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
# offers the best performance. Don't set it higher than the number of CPU
# cores if changing this parameter.
# The maximum number of connections for Nginx is calculated by:
# max_clients = worker_processes * worker_connections
worker_processes auto;
# Maximum open file descriptors per process;
# should be > worker_connections.
worker_rlimit_nofile 8192;
events {
# When you need > 8000 * cpu_cores connections, you start optimizing your OS,
# and this is probably the point at which you hire people who are smarter than
# you, as this is *a lot* of requests.
worker_connections 8000;
}
# Default error log file
# (this is only used when you don't override error_log on a server{} level)
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
http {
# Hide nginx version information.
server_tokens off;
# Define the MIME types for files.
include mime.types;
default_type application/octet-stream;
# Update charset_types to match updated mime.types.
# text/html is always included by charset module.
# Default: text/html text/xml text/plain text/vnd.wap.wml application/javascript application/rss+xml
charset_types
text/css
text/plain
text/vnd.wap.wml
application/javascript
application/json
application/rss+xml
application/xml;
# Format to use in log files
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# Default log file
# (this is only used when you don't override access_log on a server{} level)
access_log /var/log/nginx/access.log main;
# How long to allow each connection to stay idle; longer values are better
# for each individual client, particularly for SSL, but means that worker
# connections are tied up longer. (Default: 65)
keepalive_timeout 20;
# Speed up file transfers by using sendfile() to copy directly
# between descriptors rather than using read()/write().
# For performance reasons, on FreeBSD systems w/ ZFS
# this option should be disabled as ZFS's ARC caches
# frequently used files in RAM by default.
sendfile on;
# Tell Nginx not to send out partial frames; this increases throughput
# since TCP frames are filled up before being sent out. (adds TCP_CORK)
tcp_nopush on;
# Compression
# Enable Gzip compressed.
gzip on;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# text/html is always compressed by HttpGzipModule
# This should be turned on if you are going to have pre-compressed copies (.gz) of
# static files available. If not it should be left off as it will cause extra I/O
# for the check. It is best if you enable this in a location{} block for
# a specific directory, or on an individual server{} level.
# gzip_static on;
# Content type for FIDO U2F facets
map $uri $fido_content_type {
default "application/fido.trusted-apps+json";
}
# Include files in the sites-enabled folder. server{} configuration files should be
# placed in the sites-available folder, and then the configuration should be enabled
# by creating a symlink to it in the sites-enabled folder.
# See doc/sites-enabled.md for more info.
include conf.d/*.conf;
}

View File

@@ -1,3 +0,0 @@
add_header Referrer-Policy same-origin;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

View File

@@ -32,6 +32,7 @@ mkhomedir_helper $USERNAME
chown -R $USERNAME:$GROUPNAME /etc/bitwarden chown -R $USERNAME:$GROUPNAME /etc/bitwarden
cp /etc/bitwarden/web/app-id.json /app/app-id.json cp /etc/bitwarden/web/app-id.json /app/app-id.json
chown -R $USERNAME:$GROUPNAME /app chown -R $USERNAME:$GROUPNAME /app
#chown -R $USERNAME:$GROUPNAME /bitwarden_server chown -R $USERNAME:$GROUPNAME /bitwarden_server
#exec nginx -g 'daemon off;' exec gosu $USERNAME:$GROUPNAME dotnet /bitwarden_server/Server.dll \
/contentRoot=/app /webRoot=. /serveUnknown=false /webVault=true

2
jslib

Submodule jslib updated: e372bf242b...5fb0247a6a

13752
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@bitwarden/web-vault", "name": "bitwarden-web",
"version": "2.25.1", "version": "2.24.3",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": "https://github.com/bitwarden/web", "repository": "https://github.com/bitwarden/web",
"scripts": { "scripts": {
@@ -29,57 +29,44 @@
"dist:bit:selfhost": "npm run build:bit:selfhost:prod", "dist:bit:selfhost": "npm run build:bit:selfhost:prod",
"deploy": "npm run dist:bit && gh-pages -d build", "deploy": "npm run dist:bit && gh-pages -d build",
"deploy:dev": "npm run dist:bit && gh-pages -d build -r git@github.com:kspearrin/bitwarden-web-dev.git", "deploy:dev": "npm run dist:bit && gh-pages -d build -r git@github.com:kspearrin/bitwarden-web-dev.git",
"lint": "tslint 'src/**/*.ts' 'bitwarden_license/src/**/*.ts' && prettier --check .", "lint": "tslint 'src/**/*.ts' 'bitwarden_license/src/**/*.ts' || true",
"lint:fix": "tslint 'src/**/*.ts' 'bitwarden_license/src/**/*.ts' --fix", "lint:fix": "tslint 'src/**/*.ts' 'bitwarden_license/src/**/*.ts' --fix"
"prettier": "prettier --write .",
"prepare": "husky install"
}, },
"devDependencies": { "devDependencies": {
"@angular/compiler-cli": "^12.2.13", "@angular/compiler-cli": "^11.2.11",
"@ngtools/webpack": "^12.2.13", "@ngtools/webpack": "^11.2.10",
"@types/jquery": "^3.5.5", "@types/jquery": "^3.5.5",
"@types/node": "^16.11.12", "@types/node": "^14.17.2",
"@types/webcrypto": "^0.0.28", "@types/webcrypto": "^0.0.28",
"@types/webpack": "^5.28.0", "@types/webpack": "^4.4.27",
"buffer": "^6.0.3", "clean-webpack-plugin": "^3.0.0",
"clean-webpack-plugin": "^4.0.0", "copy-webpack-plugin": "^6.4.0",
"copy-webpack-plugin": "^10.0.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^6.5.1", "css-loader": "^5.2.3",
"del": "^6.0.0",
"file-loader": "^6.2.0",
"gh-pages": "^3.1.0", "gh-pages": "^3.1.0",
"html-loader": "^3.0.1", "html-loader": "^1.3.2",
"html-webpack-injector": "1.1.4", "html-webpack-injector": "1.1.4",
"html-webpack-plugin": "^5.5.0", "html-webpack-plugin": "^4.5.1",
"husky": "^7.0.4", "mini-css-extract-plugin": "^1.5.0",
"lint-staged": "^12.1.2",
"mini-css-extract-plugin": "^2.4.5",
"prettier": "2.5.1",
"process": "^0.11.10",
"sass": "^1.32.10", "sass": "^1.32.10",
"sass-loader": "^12.4.0", "sass-loader": "^10.1.1",
"style-loader": "^3.3.1", "style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.2.5", "tapable": "^1.1.3",
"ts-loader": "^9.2.5", "terser-webpack-plugin": "^4.2.3",
"ts-loader": "^8.1.0",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-loader": "^3.5.4", "tslint-loader": "^3.5.4",
"typescript": "4.3.5", "typescript": "4.1.5",
"util": "^0.12.4", "webpack": "^4.46.0",
"webpack": "^5.64.4", "webpack-cli": "^4.6.0",
"webpack-cli": "^4.9.1", "webpack-dev-server": "^3.11.2"
"webpack-dev-server": "^4.6.0"
}, },
"dependencies": { "dependencies": {
"@angular/animations": "^12.2.13",
"@angular/cdk": "^12.2.13",
"@angular/common": "^12.2.13",
"@angular/compiler": "^12.2.13",
"@angular/core": "^12.2.13",
"@angular/forms": "^12.2.13",
"@angular/platform-browser": "^12.2.13",
"@angular/platform-browser-dynamic": "^12.2.13",
"@angular/router": "^12.2.13",
"@bitwarden/jslib-angular": "file:jslib/angular", "@bitwarden/jslib-angular": "file:jslib/angular",
"@bitwarden/jslib-common": "file:jslib/common", "@bitwarden/jslib-common": "file:jslib/common",
"angular2-toaster": "11.0.1",
"bootstrap": "4.6.0", "bootstrap": "4.6.0",
"braintree-web-drop-in": "1.30.1", "braintree-web-drop-in": "1.30.1",
"browser-hrtime": "^1.1.8", "browser-hrtime": "^1.1.8",
@@ -88,20 +75,14 @@
"font-awesome": "4.7.0", "font-awesome": "4.7.0",
"jquery": "3.6.0", "jquery": "3.6.0",
"ngx-infinite-scroll": "^10.0.1", "ngx-infinite-scroll": "^10.0.1",
"ngx-toastr": "14.1.4",
"popper.js": "1.16.1", "popper.js": "1.16.1",
"qrious": "4.0.2", "qrious": "4.0.2",
"rxjs": "^7.4.0",
"sweetalert2": "^10.16.6", "sweetalert2": "^10.16.6",
"webcrypto-shim": "0.1.7", "webcrypto-shim": "0.1.7",
"whatwg-fetch": "3.6.2" "whatwg-fetch": "3.6.2"
}, },
"engines": { "engines": {
"node": "~16", "node": "~14",
"npm": "~8" "npm": "~7"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write",
"*.png": "node scripts/optimize.js"
} }
} }

View File

@@ -1,21 +0,0 @@
const child_process = require("child_process");
const path = require("path");
const images = process.argv.slice(2);
images.forEach((img) => {
switch (img.split(".").pop()) {
case "png":
child_process.execSync(
`npx @squoosh/cli --oxipng {} --output-dir "${path.dirname(img)}" "${img}"`
);
break;
case "jpg":
child_process.execSync(
`npx @squoosh/cli --mozjpeg {"quality":85,"baseline":false,"arithmetic":false,"progressive":true,"optimize_coding":true,"smoothing":0,"color_space":3,"quant_table":3,"trellis_multipass":false,"trellis_opt_zero":false,"trellis_opt_table":false,"trellis_loops":1,"auto_subsample":true,"chroma_subsample":2,"separate_chroma_quality":false,"chroma_quality":75} --output-dir "${path.dirname(
img
)}" "${img}"`
);
break;
}
});

View File

@@ -1,26 +1,24 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1">
<link <link href="/404/bootstrap.min.css" rel="stylesheet" type="text/css"
href="/404/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l">
rel="stylesheet" <link href="/404/font-awesome.min.css" rel="stylesheet" type="text/css"
type="text/css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==">
integrity="sha384-hA/ESrxp2b05ywLtD9YwM6m+pNyLRY4+ruk6dWK00SM4k6SQs0bfrITJVSf6uZyH" <link href="/404/styles.css" rel="stylesheet" type="text/css">
/>
<link href="/404/styles.css" rel="stylesheet" type="text/css" />
<link rel="apple-touch-icon" sizes="180x180" href="/images/icons/apple-touch-icon.png" /> <link rel="apple-touch-icon" sizes="180x180" href="/images/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/icons/favicon-32x32.png" /> <link rel="icon" type="image/png" sizes="32x32" href="/images/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/icons/favicon-16x16.png" /> <link rel="icon" type="image/png" sizes="16x16" href="/images/icons/favicon-16x16.png">
<link rel="mask-icon" href="/images/icons/safari-pinned-tab.svg" color="#175DDC" /> <link rel="mask-icon" href="/images/icons/safari-pinned-tab.svg" color="#175DDC">
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json">
<title>Page not found!</title> <title>Page not found!</title>
<meta name="description" content="404 Page Not Found" /> <meta name="description" content="404 Page Not Found">
</head> </head>
<body> <body>
@@ -28,7 +26,8 @@
<div class="container inner banner"> <div class="container inner banner">
<div class="row align-items-center"> <div class="row align-items-center">
<div class="col brand"> <div class="col brand">
<i class="bwi bwi-shield"></i>&nbsp; <strong>bit</strong>warden <i class="fa fa-shield"></i>&nbsp;
<strong>bit</strong>warden</span>
</div> </div>
</div> </div>
</div> </div>
@@ -38,15 +37,14 @@
<p>Sorry, but the page you were looking for could not be found.</p> <p>Sorry, but the page you were looking for could not be found.</p>
<p> <p>
<a href="/"> <a href="/">
<img src="/images/404.png" class="img-fluid" alt="404 image" width="80%" /> <img src="/images/404.png" class="img-fluid" alt="404 image" width="80%"/>
</a> </a>
</p> </p>
<p> <p>You can <a href="/">return to the web vault</a>, check our <a href="https://status.bitwarden.com/">status page</a>
You can <a href="/">return to the web vault</a>, check our or <a href="https://bitwarden.com/contact/">contact us</a>.</p>
<a href="https://status.bitwarden.com/">status page</a> or </div>
<a href="https://bitwarden.com/contact/">contact us</a>. <div class="container footer text-muted content">
</p> © Copyright 2021 Bitwarden, Inc.
</div> </div>
<div class="container footer text-muted content">© Copyright 2022 Bitwarden, Inc.</div>
</body> </body>
</html> </html>

4
src/404/font-awesome.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,90 +1,88 @@
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: italic; font-style: italic;
font-weight: 300; font-weight: 300;
src: url(../fonts/Open_Sans-italic-300.woff) format("woff"); src: url(../fonts/Open_Sans-italic-300.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: italic; font-style: italic;
font-weight: 400; font-weight: 400;
src: url(../fonts/Open_Sans-italic-400.woff) format("woff"); src: url(../fonts/Open_Sans-italic-400.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: italic; font-style: italic;
font-weight: 600; font-weight: 600;
src: url(../fonts/Open_Sans-italic-600.woff) format("woff"); src: url(../fonts/Open_Sans-italic-600.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: italic; font-style: italic;
font-weight: 700; font-weight: 700;
src: url(../fonts/Open_Sans-italic-700.woff) format("woff"); src: url(../fonts/Open_Sans-italic-700.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: italic; font-style: italic;
font-weight: 800; font-weight: 800;
src: url(../fonts/Open_Sans-italic-800.woff) format("woff"); src: url(../fonts/Open_Sans-italic-800.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 300; font-weight: 300;
src: url(../fonts/Open_Sans-normal-300.woff) format("woff"); src: url(../fonts/Open_Sans-normal-300.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url(../fonts/Open_Sans-normal-400.woff) format("woff"); src: url(../fonts/Open_Sans-normal-400.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 600; font-weight: 600;
src: url(../fonts/Open_Sans-normal-600.woff) format("woff"); src: url(../fonts/Open_Sans-normal-600.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 700; font-weight: 700;
src: url(../fonts/Open_Sans-normal-700.woff) format("woff"); src: url(../fonts/Open_Sans-normal-700.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
@font-face { @font-face {
font-family: "Open Sans"; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 800; font-weight: 800;
src: url(../fonts/Open_Sans-normal-800.woff) format("woff"); src: url(../fonts/Open_Sans-normal-800.woff) format('woff');
unicode-range: U+0-10FFFF; unicode-range: U+0-10FFFF;
} }
body { body {
font-family: "Open Sans"; font-family: 'Open Sans';
} }
html, html, body, .row {
body,
.row {
height: 100%; height: 100%;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
@@ -100,11 +98,11 @@ h2 {
font-size: 23px; font-size: 23px;
line-height: 25px; line-height: 25px;
color: #fff; color: #fff;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
} }
.banner { .banner {
background-color: #175ddc; background-color: #175DDC;
height: 56px; height: 56px;
} }
@@ -119,33 +117,3 @@ h2 {
padding: 40px 0 40px 0; padding: 40px 0 40px 0;
border-top: 1px solid #dee2e6; border-top: 1px solid #dee2e6;
} }
/* Bitwarden icons, manually copied */
@font-face {
font-family: "bwi-font";
src: url(../images/bwi-font.svg) format("svg"), url(../fonts/bwi-font.ttf) format("truetype"),
url(../fonts/bwi-font.woff) format("woff"), url(../fonts/bwi-font.woff2) format("woff2");
font-weight: normal;
font-style: normal;
font-display: block;
}
.bwi {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: "bwi-font" !important;
speak: never;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
display: inline-block;
/* Better Font Rendering */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.bwi-shield:before {
content: "\e932";
}

View File

@@ -1,37 +1,30 @@
<div class="mt-5 d-flex justify-content-center" *ngIf="loading"> <div class="mt-5 d-flex justify-content-center" *ngIf="loading">
<div> <div>
<img class="mb-4 logo logo-themed" alt="Bitwarden" /> <img class="mb-4 logo logo-themed" alt="Bitwarden">
<p class="text-center"> <p class="text-center">
<i <i class="fa fa-spinner fa-spin fa-2x text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin bwi-2x text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</p> </p>
</div> </div>
</div> </div>
<div class="container" *ngIf="!loading && !authed"> <div class="container" *ngIf="!loading && !authed">
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "emergencyAccess" | i18n }}</p> <p class="lead text-center mb-4">{{'emergencyAccess' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<p class="text-center"> <p class="text-center">
{{ name }} {{name}}
</p> </p>
<p>{{ "acceptEmergencyAccess" | i18n }}</p> <p>{{'acceptEmergencyAccess' | i18n}}</p>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<a routerLink="/" [queryParams]="{ email: email }" class="btn btn-primary btn-block"> <a routerLink="/" [queryParams]="{email: email}" class="btn btn-primary btn-block">
{{ "logIn" | i18n }} {{'logIn' | i18n}}
</a> </a>
<a <a routerLink="/register" [queryParams]="{email: email}"
routerLink="/register" class="btn btn-primary btn-block ml-2 mt-0">
[queryParams]="{ email: email }" {{'createAccount' | i18n}}
class="btn btn-primary btn-block ml-2 mt-0"
>
{{ "createAccount" | i18n }}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,33 +1,38 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import {
ActivatedRoute,
Router,
} from '@angular/router';
import { ApiService } from "jslib-common/abstractions/api.service"; import {
import { I18nService } from "jslib-common/abstractions/i18n.service"; Toast,
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; ToasterService,
import { StateService } from "jslib-common/abstractions/state.service"; } from 'angular2-toaster';
import { EmergencyAccessAcceptRequest } from "jslib-common/models/request/emergencyAccessAcceptRequest";
import { BaseAcceptComponent } from "../common/base.accept.component"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { EmergencyAccessAcceptRequest } from 'jslib-common/models/request/emergencyAccessAcceptRequest';
import { BaseAcceptComponent } from '../common/base.accept.component';
@Component({ @Component({
selector: "app-accept-emergency", selector: 'app-accept-emergency',
templateUrl: "accept-emergency.component.html", templateUrl: 'accept-emergency.component.html',
}) })
export class AcceptEmergencyComponent extends BaseAcceptComponent { export class AcceptEmergencyComponent extends BaseAcceptComponent {
name: string; name: string;
protected requiredParameters: string[] = ["id", "name", "email", "token"]; protected requiredParameters: string[] = ['id', 'name', 'email', 'token'];
protected failedShortMessage = "emergencyInviteAcceptFailedShort"; protected failedShortMessage = 'emergencyInviteAcceptFailedShort';
protected failedMessage = "emergencyInviteAcceptFailed"; protected failedMessage = 'emergencyInviteAcceptFailed';
constructor( constructor(router: Router, toasterService: ToasterService,
router: Router, i18nService: I18nService, route: ActivatedRoute,
platformUtilsService: PlatformUtilsService, private apiService: ApiService, userService: UserService,
i18nService: I18nService, stateService: StateService) {
route: ActivatedRoute, super(router, toasterService, i18nService, route, userService, stateService);
private apiService: ApiService,
stateService: StateService
) {
super(router, platformUtilsService, i18nService, route, stateService);
} }
async authedHandler(qParams: any): Promise<void> { async authedHandler(qParams: any): Promise<void> {
@@ -35,20 +40,21 @@ export class AcceptEmergencyComponent extends BaseAcceptComponent {
request.token = qParams.token; request.token = qParams.token;
this.actionPromise = this.apiService.postEmergencyAccessAccept(qParams.id, request); this.actionPromise = this.apiService.postEmergencyAccessAccept(qParams.id, request);
await this.actionPromise; await this.actionPromise;
this.platformUtilService.showToast( const toast: Toast = {
"success", type: 'success',
this.i18nService.t("inviteAccepted"), title: this.i18nService.t('inviteAccepted'),
this.i18nService.t("emergencyInviteAcceptedDesc"), body: this.i18nService.t('emergencyInviteAcceptedDesc'),
{ timeout: 10000 } timeout: 10000,
); };
this.router.navigate(["/vault"]); this.toasterService.popAsync(toast);
this.router.navigate(['/vault']);
} }
async unauthedHandler(qParams: any): Promise<void> { async unauthedHandler(qParams: any): Promise<void> {
this.name = qParams.name; this.name = qParams.name;
if (this.name != null) { if (this.name != null) {
// Fix URL encoding of space issue with Angular // Fix URL encoding of space issue with Angular
this.name = this.name.replace(/\+/g, " "); this.name = this.name.replace(/\+/g, ' ');
} }
} }
} }

View File

@@ -1,38 +1,31 @@
<div class="mt-5 d-flex justify-content-center" *ngIf="loading"> <div class="mt-5 d-flex justify-content-center" *ngIf="loading">
<div> <div>
<img src="../../images/logo-dark@2x.png" class="mb-4 logo" alt="Bitwarden" /> <img src="../../images/logo-dark@2x.png" class="mb-4 logo" alt="Bitwarden">
<p class="text-center"> <p class="text-center">
<i <i class="fa fa-spinner fa-spin fa-2x text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
class="bwi bwi-spinner bwi-spin bwi-2x text-muted" <span class="sr-only">{{'loading' | i18n}}</span>
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</p> </p>
</div> </div>
</div> </div>
<div class="container" *ngIf="!loading && !authed"> <div class="container" *ngIf="!loading && !authed">
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "joinOrganization" | i18n }}</p> <p class="lead text-center mb-4">{{'joinOrganization' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<p class="text-center"> <p class="text-center">
{{ orgName }} {{orgName}}
<strong class="d-block mt-2">{{ email }}</strong> <strong class="d-block mt-2">{{email}}</strong>
</p> </p>
<p>{{ "joinOrganizationDesc" | i18n }}</p> <p>{{'joinOrganizationDesc' | i18n}}</p>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<a routerLink="/" [queryParams]="{ email: email }" class="btn btn-primary btn-block"> <a routerLink="/" [queryParams]="{email: email}" class="btn btn-primary btn-block">
{{ "logIn" | i18n }} {{'logIn' | i18n}}
</a> </a>
<a <a routerLink="/register" [queryParams]="{email: email}"
routerLink="/register" class="btn btn-primary btn-block ml-2 mt-0">
[queryParams]="{ email: email }" {{'createAccount' | i18n}}
class="btn btn-primary btn-block ml-2 mt-0"
>
{{ "createAccount" | i18n }}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,57 +1,56 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import {
ActivatedRoute,
Router,
} from '@angular/router';
import { ApiService } from "jslib-common/abstractions/api.service"; import {
import { CryptoService } from "jslib-common/abstractions/crypto.service"; Toast,
import { I18nService } from "jslib-common/abstractions/i18n.service"; ToasterService,
import { LogService } from "jslib-common/abstractions/log.service"; } from 'angular2-toaster';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service";
import { OrganizationUserAcceptRequest } from "jslib-common/models/request/organizationUserAcceptRequest"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { OrganizationUserResetPasswordEnrollmentRequest } from "jslib-common/models/request/organizationUserResetPasswordEnrollmentRequest"; import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { Utils } from "jslib-common/misc/utils"; import { OrganizationUserAcceptRequest } from 'jslib-common/models/request/organizationUserAcceptRequest';
import { Policy } from "jslib-common/models/domain/policy"; import { OrganizationUserResetPasswordEnrollmentRequest } from 'jslib-common/models/request/organizationUserResetPasswordEnrollmentRequest';
import { BaseAcceptComponent } from "../common/base.accept.component";
import { Utils } from 'jslib-common/misc/utils';
import { Policy } from 'jslib-common/models/domain/policy';
import { BaseAcceptComponent } from '../common/base.accept.component';
@Component({ @Component({
selector: "app-accept-organization", selector: 'app-accept-organization',
templateUrl: "accept-organization.component.html", templateUrl: 'accept-organization.component.html',
}) })
export class AcceptOrganizationComponent extends BaseAcceptComponent { export class AcceptOrganizationComponent extends BaseAcceptComponent {
orgName: string; orgName: string;
protected requiredParameters: string[] = ["organizationId", "organizationUserId", "token"]; protected requiredParameters: string[] = ['organizationId', 'organizationUserId', 'token'];
constructor( constructor(router: Router, toasterService: ToasterService,
router: Router, i18nService: I18nService, route: ActivatedRoute,
platformUtilsService: PlatformUtilsService, private apiService: ApiService, userService: UserService,
i18nService: I18nService, stateService: StateService, private cryptoService: CryptoService,
route: ActivatedRoute, private policyService: PolicyService) {
private apiService: ApiService, super(router, toasterService, i18nService, route, userService, stateService);
stateService: StateService,
private cryptoService: CryptoService,
private policyService: PolicyService,
private logService: LogService
) {
super(router, platformUtilsService, i18nService, route, stateService);
} }
async authedHandler(qParams: any): Promise<void> { async authedHandler(qParams: any): Promise<void> {
const request = new OrganizationUserAcceptRequest(); const request = new OrganizationUserAcceptRequest();
request.token = qParams.token; request.token = qParams.token;
if (await this.performResetPasswordAutoEnroll(qParams)) { if (await this.performResetPasswordAutoEnroll(qParams)) {
this.actionPromise = this.apiService this.actionPromise = this.apiService.postOrganizationUserAccept(qParams.organizationId,
.postOrganizationUserAccept(qParams.organizationId, qParams.organizationUserId, request) qParams.organizationUserId, request).then(() => {
.then(() => {
// Retrieve Public Key // Retrieve Public Key
return this.apiService.getOrganizationKeys(qParams.organizationId); return this.apiService.getOrganizationKeys(qParams.organizationId);
}) }).then(async response => {
.then(async (response) => {
if (response == null) { if (response == null) {
throw new Error(this.i18nService.t("resetPasswordOrgKeysError")); throw new Error(this.i18nService.t('resetPasswordOrgKeysError'));
} }
const publicKey = Utils.fromB64ToArray(response.publicKey); const publicKey = Utils.fromB64ToArray(response.publicKey);
@@ -64,60 +63,48 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
const resetRequest = new OrganizationUserResetPasswordEnrollmentRequest(); const resetRequest = new OrganizationUserResetPasswordEnrollmentRequest();
resetRequest.resetPasswordKey = encryptedKey.encryptedString; resetRequest.resetPasswordKey = encryptedKey.encryptedString;
return this.apiService.putOrganizationUserResetPasswordEnrollment( // Get User Id
qParams.organizationId, const userId = await this.userService.getUserId();
await this.stateService.getUserId(),
resetRequest return this.apiService.putOrganizationUserResetPasswordEnrollment(qParams.organizationId, userId, resetRequest);
);
}); });
} else { } else {
this.actionPromise = this.apiService.postOrganizationUserAccept( this.actionPromise = this.apiService.postOrganizationUserAccept(qParams.organizationId,
qParams.organizationId, qParams.organizationUserId, request);
qParams.organizationUserId,
request
);
} }
await this.actionPromise; await this.actionPromise;
this.platformUtilService.showToast( const toast: Toast = {
"success", type: 'success',
this.i18nService.t("inviteAccepted"), title: this.i18nService.t('inviteAccepted'),
this.i18nService.t("inviteAcceptedDesc"), body: this.i18nService.t('inviteAcceptedDesc'),
{ timeout: 10000 } timeout: 10000,
); };
this.toasterService.popAsync(toast);
await this.stateService.setOrganizationInvitation(null); await this.stateService.remove('orgInvitation');
this.router.navigate(["/vault"]); this.router.navigate(['/vault']);
} }
async unauthedHandler(qParams: any): Promise<void> { async unauthedHandler(qParams: any): Promise<void> {
this.orgName = qParams.organizationName; this.orgName = qParams.organizationName;
if (this.orgName != null) { if (this.orgName != null) {
// Fix URL encoding of space issue with Angular // Fix URL encoding of space issue with Angular
this.orgName = this.orgName.replace(/\+/g, " "); this.orgName = this.orgName.replace(/\+/g, ' ');
} }
await this.stateService.setOrganizationInvitation(qParams); await this.stateService.save('orgInvitation', qParams);
} }
private async performResetPasswordAutoEnroll(qParams: any): Promise<boolean> { private async performResetPasswordAutoEnroll(qParams: any): Promise<boolean> {
let policyList: Policy[] = null; let policyList: Policy[] = null;
try { try {
const policies = await this.apiService.getPoliciesByToken( const policies = await this.apiService.getPoliciesByToken(qParams.organizationId, qParams.token,
qParams.organizationId, qParams.email, qParams.organizationUserId);
qParams.token,
qParams.email,
qParams.organizationUserId
);
policyList = this.policyService.mapPoliciesFromToken(policies); policyList = this.policyService.mapPoliciesFromToken(policies);
} catch (e) { } catch { }
this.logService.error(e);
}
if (policyList != null) { if (policyList != null) {
const result = this.policyService.getResetPasswordPolicyOptions( const result = this.policyService.getResetPasswordPolicyOptions(policyList, qParams.organizationId);
policyList,
qParams.organizationId
);
// Return true if policy enabled and auto-enroll enabled // Return true if policy enabled and auto-enroll enabled
return result[1] && result[0].autoEnrollEnabled; return result[1] && result[0].autoEnrollEnabled;
} }

View File

@@ -1,40 +1,23 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate>
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "passwordHint" | i18n }}</p> <p class="lead text-center mb-4">{{'passwordHint' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
<label for="email">{{ "emailAddress" | i18n }}</label> <label for="email">{{'emailAddress' | i18n}}</label>
<input <input id="email" class="form-control" type="text" name="Email" [(ngModel)]="email" required
id="email" appAutofocus inputmode="email" appInputVerbatim="false">
class="form-control" <small class="form-text text-muted">{{'enterEmailToGetHint' | i18n}}</small>
type="text"
name="Email"
[(ngModel)]="email"
required
appAutofocus
inputmode="email"
appInputVerbatim="false"
/>
<small class="form-text text-muted">{{ "enterEmailToGetHint" | i18n }}</small>
</div> </div>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<button <button type="submit" class="btn btn-primary btn-block btn-submit" [disabled]="form.loading">
type="submit" <span [hidden]="form.loading">{{'submit' | i18n}}</span>
class="btn btn-primary btn-block btn-submit" <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
[disabled]="form.loading"
>
<span [hidden]="form.loading">{{ "submit" | i18n }}</span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
<a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0"> <a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0">
{{ "cancel" | i18n }} {{'cancel' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,25 +1,19 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { Router } from "@angular/router"; import { Router } from '@angular/router';
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 { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from "jslib-common/abstractions/log.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { HintComponent as BaseHintComponent } from "jslib-angular/components/hint.component"; import { HintComponent as BaseHintComponent } from 'jslib-angular/components/hint.component';
@Component({ @Component({
selector: "app-hint", selector: 'app-hint',
templateUrl: "hint.component.html", templateUrl: 'hint.component.html',
}) })
export class HintComponent extends BaseHintComponent { export class HintComponent extends BaseHintComponent {
constructor( constructor(router: Router, i18nService: I18nService,
router: Router, apiService: ApiService, platformUtilsService: PlatformUtilsService) {
i18nService: I18nService, super(router, i18nService, apiService, platformUtilsService);
apiService: ApiService,
platformUtilsService: PlatformUtilsService,
logService: LogService
) {
super(router, i18nService, apiService, platformUtilsService, logService);
} }
} }

View File

@@ -2,61 +2,37 @@
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="text-center mb-4"> <p class="text-center mb-4">
<i class="bwi bwi-lock bwi-4x text-muted" aria-hidden="true"></i> <i class="fa fa-lock fa-4x text-muted" aria-hidden="true"></i>
</p> </p>
<p class="lead text-center mx-4 mb-4">{{ "yourVaultIsLocked" | i18n }}</p> <p class="lead text-center mx-4 mb-4">{{'yourVaultIsLocked' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
<label for="masterPassword">{{ "masterPass" | i18n }}</label> <label for="masterPassword">{{'masterPass' | i18n}}</label>
<div class="d-flex"> <div class="d-flex">
<input <input id="masterPassword" type="{{showPassword ? 'text' : 'password'}}"
id="masterPassword" name="MasterPassword" class="text-monospace form-control" [(ngModel)]="masterPassword"
type="{{ showPassword ? 'text' : 'password' }}" required appAutofocus appInputVerbatim>
name="MasterPassword" <button type="button" class="ml-1 btn btn-link" appA11yTitle="{{'toggleVisibility' | i18n}}"
class="text-monospace form-control" (click)="togglePassword()">
[(ngModel)]="masterPassword" <i class="fa fa-lg" aria-hidden="true"
required [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
appAutofocus
appInputVerbatim
/>
<button
type="button"
class="ml-1 btn btn-link"
appA11yTitle="{{ 'toggleVisibility' | i18n }}"
(click)="togglePassword()"
>
<i
class="bwi bwi-lg"
aria-hidden="true"
[ngClass]="{ 'bwi-eye': !showPassword, 'bwi-eye-slash': showPassword }"
></i>
</button> </button>
</div> </div>
<small class="text-muted form-text"> <small class="text-muted form-text">
{{ "loggedInAsEmailOn" | i18n: email:webVaultHostname }} {{'loggedInAsEmailOn' | i18n : email : webVaultHostname}}
</small> </small>
</div> </div>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<button <button type="submit" class="btn btn-primary btn-block btn-submit" [disabled]="form.loading">
type="submit" <span>
class="btn btn-primary btn-block btn-submit" <i class="fa fa-unlock-alt" aria-hidden="true"></i> {{'unlock' | i18n}}
[disabled]="form.loading" </span>
> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span> <i class="bwi bwi-unlock" aria-hidden="true"></i> {{ "unlock" | i18n }} </span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
<button <button type="button" class="btn btn-outline-secondary btn-block ml-2 mt-0" (click)="logOut()">
type="button" {{'logOut' | i18n}}
class="btn btn-outline-secondary btn-block ml-2 mt-0"
(click)="logOut()"
>
{{ "logOut" | i18n }}
</button> </button>
</div> </div>
</div> </div>

View File

@@ -1,62 +1,41 @@
import { Component, NgZone } from "@angular/core"; import { Component } from '@angular/core';
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from "jslib-common/abstractions/crypto.service"; import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EnvironmentService } from "jslib-common/abstractions/environment.service"; import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from "jslib-common/abstractions/i18n.service"; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { KeyConnectorService } from "jslib-common/abstractions/keyConnector.service"; import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { LogService } from "jslib-common/abstractions/log.service"; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { MessagingService } from "jslib-common/abstractions/messaging.service"; import { StateService } from 'jslib-common/abstractions/state.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { StorageService } from 'jslib-common/abstractions/storage.service';
import { StateService } from "jslib-common/abstractions/state.service"; import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service"; import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { RouterService } from "../services/router.service"; import { RouterService } from '../services/router.service';
import { LockComponent as BaseLockComponent } from "jslib-angular/components/lock.component"; import { LockComponent as BaseLockComponent } from 'jslib-angular/components/lock.component';
@Component({ @Component({
selector: "app-lock", selector: 'app-lock',
templateUrl: "lock.component.html", templateUrl: 'lock.component.html',
}) })
export class LockComponent extends BaseLockComponent { export class LockComponent extends BaseLockComponent {
constructor( constructor(router: Router, i18nService: I18nService,
router: Router, platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
i18nService: I18nService, userService: UserService, cryptoService: CryptoService,
platformUtilsService: PlatformUtilsService, storageService: StorageService, vaultTimeoutService: VaultTimeoutService,
messagingService: MessagingService, environmentService: EnvironmentService, private routerService: RouterService,
cryptoService: CryptoService, stateService: StateService, apiService: ApiService) {
vaultTimeoutService: VaultTimeoutService, super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService,
environmentService: EnvironmentService, storageService, vaultTimeoutService, environmentService, stateService, apiService);
private routerService: RouterService,
stateService: StateService,
apiService: ApiService,
logService: LogService,
keyConnectorService: KeyConnectorService,
ngZone: NgZone
) {
super(
router,
i18nService,
platformUtilsService,
messagingService,
cryptoService,
vaultTimeoutService,
environmentService,
stateService,
apiService,
logService,
keyConnectorService,
ngZone
);
} }
async ngOnInit() { async ngOnInit() {
await super.ngOnInit(); await super.ngOnInit();
this.onSuccessfulSubmit = async () => { this.onSuccessfulSubmit = () => {
const previousUrl = this.routerService.getPreviousUrl(); const previousUrl = this.routerService.getPreviousUrl();
if (previousUrl !== "/" && previousUrl.indexOf("lock") === -1) { if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) {
this.successRoute = previousUrl; this.successRoute = previousUrl;
} }
this.router.navigate([this.successRoute]); this.router.navigate([this.successRoute]);

View File

@@ -1,98 +1,57 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate>
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<img class="mb-2 logo logo-themed" alt="Bitwarden" /> <img class="mb-2 logo logo-themed" alt="Bitwarden">
<p class="lead text-center mx-4 mb-4">{{ "loginOrCreateNewAccount" | i18n }}</p> <p class="lead text-center mx-4 mb-4">{{'loginOrCreateNewAccount' | i18n}}</p>
<div class="card d-block"> <div class="card d-block">
<div class="card-body"> <div class="card-body">
<app-callout <app-callout type="warning" title="{{'resetPasswordPolicyAutoEnroll' | i18n}}"
type="warning" *ngIf="showResetPasswordAutoEnrollWarning">
title="{{ 'resetPasswordPolicyAutoEnroll' | i18n }}" {{'resetPasswordAutoEnrollInviteWarning' | i18n}}
*ngIf="showResetPasswordAutoEnrollWarning"
>
{{ "resetPasswordAutoEnrollInviteWarning" | i18n }}
</app-callout> </app-callout>
<div class="form-group"> <div class="form-group">
<label for="email">{{ "emailAddress" | i18n }}</label> <label for="email">{{'emailAddress' | i18n}}</label>
<input <input id="email" class="form-control" type="text" name="Email" [(ngModel)]="email" required
id="email" inputmode="email" appInputVerbatim="false">
class="form-control"
type="text"
name="Email"
[(ngModel)]="email"
required
inputmode="email"
appInputVerbatim="false"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="masterPassword">{{ "masterPass" | i18n }}</label> <label for="masterPassword">{{'masterPass' | i18n}}</label>
<div class="d-flex"> <div class="d-flex">
<input <input id="masterPassword" type="{{showPassword ? 'text' : 'password'}}"
id="masterPassword" name="MasterPassword" class="text-monospace form-control" [(ngModel)]="masterPassword"
type="{{ showPassword ? 'text' : 'password' }}" required appInputVerbatim>
name="MasterPassword" <button type="button" class="ml-1 btn btn-link" appA11yTitle="{{'toggleVisibility' | i18n}}"
class="text-monospace form-control" (click)="togglePassword()">
[(ngModel)]="masterPassword" <i class="fa fa-lg" aria-hidden="true"
required [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
appInputVerbatim
/>
<button
type="button"
class="ml-1 btn btn-link"
appA11yTitle="{{ 'toggleVisibility' | i18n }}"
(click)="togglePassword()"
>
<i
class="bwi bwi-lg"
aria-hidden="true"
[ngClass]="{ 'bwi-eye': !showPassword, 'bwi-eye-slash': showPassword }"
></i>
</button> </button>
</div> </div>
<small class="form-text"> <small class="form-text">
<a routerLink="/hint">{{ "getMasterPasswordHint" | i18n }}</a> <a routerLink="/hint">{{'getMasterPasswordHint' | i18n}}</a>
</small> </small>
</div> </div>
<div class="form-check mb-3"> <div class="form-check mb-3">
<input <input type="checkbox" class="form-check-input" id="rememberEmail" name="RememberEmail"
type="checkbox" [(ngModel)]="rememberEmail">
class="form-check-input" <label class="form-check-label" for="rememberEmail">{{'rememberEmail' | i18n}}</label>
id="rememberEmail"
name="RememberEmail"
[(ngModel)]="rememberEmail"
/>
<label class="form-check-label" for="rememberEmail">{{ "rememberEmail" | i18n }}</label>
</div> </div>
<div class="mb-n3" [hidden]="!showCaptcha()"> <div class="mb-n3" [hidden]="!showCaptcha()"><iframe id="hcaptcha_iframe" height="80"></iframe></div>
<iframe id="hcaptcha_iframe" height="80"></iframe> <hr>
</div>
<hr />
<div class="d-flex"> <div class="d-flex">
<button <button type="submit" class="btn btn-primary btn-block btn-submit" [disabled]="form.loading">
type="submit" <span>
class="btn btn-primary btn-block btn-submit" <i class="fa fa-sign-in" aria-hidden="true"></i> {{'logIn' | i18n}}
[disabled]="form.loading" </span>
> <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span> <i class="bwi bwi-sign-in" aria-hidden="true"></i> {{ "logIn" | i18n }} </span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
<a <a routerLink="/register" [queryParams]="{email: email}"
routerLink="/register" class="btn btn-outline-secondary btn-block ml-2 mt-0">
[queryParams]="{ email: email }" <i class="fa fa-pencil-square-o" aria-hidden="true"></i> {{'createAccount' | i18n}}
class="btn btn-outline-secondary btn-block ml-2 mt-0"
>
<i class="bwi bwi-pencil-square-o" aria-hidden="true"></i>
{{ "createAccount" | i18n }}
</a> </a>
</div> </div>
<div class="d-flex"> <div class="d-flex">
<a routerLink="/sso" class="btn btn-outline-secondary btn-block mt-2"> <a routerLink="/sso" class="btn btn-outline-secondary btn-block mt-2">
<i class="bwi bwi-bank" aria-hidden="true"></i> {{ "enterpriseSingleSignOn" | i18n }} <i class="fa fa-bank" aria-hidden="true"></i> {{'enterpriseSingleSignOn' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,105 +1,74 @@
import { Component, NgZone } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import {
ActivatedRoute,
Router,
} from '@angular/router';
import { first } from "rxjs/operators"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { ApiService } from "jslib-common/abstractions/api.service"; import { LoginComponent as BaseLoginComponent } from 'jslib-angular/components/login.component';
import { AuthService } from "jslib-common/abstractions/auth.service";
import { CryptoFunctionService } from "jslib-common/abstractions/cryptoFunction.service";
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service";
import { LoginComponent as BaseLoginComponent } from "jslib-angular/components/login.component"; import { Policy } from 'jslib-common/models/domain/policy';
import { Policy } from "jslib-common/models/domain/policy";
@Component({ @Component({
selector: "app-login", selector: 'app-login',
templateUrl: "login.component.html", templateUrl: 'login.component.html',
}) })
export class LoginComponent extends BaseLoginComponent { export class LoginComponent extends BaseLoginComponent {
showResetPasswordAutoEnrollWarning = false; showResetPasswordAutoEnrollWarning = false;
constructor( constructor(authService: AuthService, router: Router,
authService: AuthService, i18nService: I18nService, private route: ActivatedRoute,
router: Router, storageService: StorageService, stateService: StateService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService,
private route: ActivatedRoute, passwordGenerationService: PasswordGenerationService, cryptoFunctionService: CryptoFunctionService,
stateService: StateService, private apiService: ApiService, private policyService: PolicyService) {
platformUtilsService: PlatformUtilsService, super(authService, router,
environmentService: EnvironmentService, platformUtilsService, i18nService,
passwordGenerationService: PasswordGenerationService, stateService, environmentService,
cryptoFunctionService: CryptoFunctionService, passwordGenerationService, cryptoFunctionService,
private apiService: ApiService, storageService);
private policyService: PolicyService,
logService: LogService,
ngZone: NgZone
) {
super(
authService,
router,
platformUtilsService,
i18nService,
stateService,
environmentService,
passwordGenerationService,
cryptoFunctionService,
logService,
ngZone
);
this.onSuccessfulLoginNavigate = this.goAfterLogIn; this.onSuccessfulLoginNavigate = this.goAfterLogIn;
} }
async ngOnInit() { async ngOnInit() {
this.route.queryParams.pipe(first()).subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
if (qParams.email != null && qParams.email.indexOf("@") > -1) { if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email; this.email = qParams.email;
} }
if (qParams.premium != null) { if (qParams.premium != null) {
this.stateService.setLoginRedirect({ route: "/settings/premium" }); this.stateService.save('loginRedirect', { route: '/settings/premium' });
} else if (qParams.org != null) { } else if (qParams.org != null) {
this.stateService.setLoginRedirect({ this.stateService.save('loginRedirect',
route: "/settings/create-organization", { route: '/settings/create-organization', qParams: { plan: qParams.org } });
qParams: { plan: qParams.org },
});
}
// Are they coming from an email for sponsoring a families organization
if (qParams.sponsorshipToken != null) {
// After logging in redirect them to setup the families sponsorship
this.stateService.setLoginRedirect({
route: "/setup/families-for-enterprise",
qParams: { token: qParams.sponsorshipToken },
});
} }
await super.ngOnInit(); await super.ngOnInit();
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
}); });
const invite = await this.stateService.getOrganizationInvitation(); const invite = await this.stateService.get<any>('orgInvitation');
if (invite != null) { if (invite != null) {
let policyList: Policy[] = null; let policyList: Policy[] = null;
try { try {
const policies = await this.apiService.getPoliciesByToken( const policies = await this.apiService.getPoliciesByToken(invite.organizationId, invite.token,
invite.organizationId, invite.email, invite.organizationUserId);
invite.token,
invite.email,
invite.organizationUserId
);
policyList = this.policyService.mapPoliciesFromToken(policies); policyList = this.policyService.mapPoliciesFromToken(policies);
} catch (e) { } catch { }
this.logService.error(e);
}
if (policyList != null) { if (policyList != null) {
const result = this.policyService.getResetPasswordPolicyOptions( const result = this.policyService.getResetPasswordPolicyOptions(policyList, invite.organizationId);
policyList,
invite.organizationId
);
// Set to true if policy enabled and auto-enroll enabled // Set to true if policy enabled and auto-enroll enabled
this.showResetPasswordAutoEnrollWarning = result[1] && result[0].autoEnrollEnabled; this.showResetPasswordAutoEnrollWarning = result[1] && result[0].autoEnrollEnabled;
} }
@@ -107,10 +76,10 @@ export class LoginComponent extends BaseLoginComponent {
} }
async goAfterLogIn() { async goAfterLogIn() {
const loginRedirect = await this.stateService.getLoginRedirect(); const loginRedirect = await this.stateService.get<any>('loginRedirect');
if (loginRedirect != null) { if (loginRedirect != null) {
this.router.navigate([loginRedirect.route], { queryParams: loginRedirect.qParams }); this.router.navigate([loginRedirect.route], { queryParams: loginRedirect.qParams });
await this.stateService.setLoginRedirect(null); await this.stateService.remove('loginRedirect');
} else { } else {
this.router.navigate([this.successRoute]); this.router.navigate([this.successRoute]);
} }

View File

@@ -1,40 +1,23 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate>
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "deleteAccount" | i18n }}</p> <p class="lead text-center mb-4">{{'deleteAccount' | i18n}}</p>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<p>{{ "deleteRecoverDesc" | i18n }}</p> <p>{{'deleteRecoverDesc' | i18n}}</p>
<div class="form-group"> <div class="form-group">
<label for="email">{{ "emailAddress" | i18n }}</label> <label for="email">{{'emailAddress' | i18n}}</label>
<input <input id="email" class="form-control" type="text" name="Email" [(ngModel)]="email" required
id="email" appAutofocus inputmode="email" appInputVerbatim="false">
class="form-control"
type="text"
name="Email"
[(ngModel)]="email"
required
appAutofocus
inputmode="email"
appInputVerbatim="false"
/>
</div> </div>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<button <button type="submit" class="btn btn-primary btn-block btn-submit" [disabled]="form.loading">
type="submit" <span>{{'submit' | i18n}}</span>
class="btn btn-primary btn-block btn-submit" <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
[disabled]="form.loading"
>
<span>{{ "submit" | i18n }}</span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
<a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0"> <a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0">
{{ "cancel" | i18n }} {{'cancel' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,28 +1,24 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ToasterService } from 'angular2-toaster';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { DeleteRecoverRequest } from "jslib-common/models/request/deleteRecoverRequest"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { DeleteRecoverRequest } from 'jslib-common/models/request/deleteRecoverRequest';
@Component({ @Component({
selector: "app-recover-delete", selector: 'app-recover-delete',
templateUrl: "recover-delete.component.html", templateUrl: 'recover-delete.component.html',
}) })
export class RecoverDeleteComponent { export class RecoverDeleteComponent {
email: string; email: string;
formPromise: Promise<any>; formPromise: Promise<any>;
constructor( constructor(private router: Router, private apiService: ApiService,
private router: Router, private toasterService: ToasterService, private i18nService: I18nService) {
private apiService: ApiService, }
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private logService: LogService
) {}
async submit() { async submit() {
try { try {
@@ -30,14 +26,8 @@ export class RecoverDeleteComponent {
request.email = this.email.trim().toLowerCase(); request.email = this.email.trim().toLowerCase();
this.formPromise = this.apiService.postAccountRecoverDelete(request); this.formPromise = this.apiService.postAccountRecoverDelete(request);
await this.formPromise; await this.formPromise;
this.platformUtilsService.showToast( this.toasterService.popAsync('success', null, this.i18nService.t('deleteRecoverEmailSent'));
"success", this.router.navigate(['/']);
null, } catch { }
this.i18nService.t("deleteRecoverEmailSent")
);
this.router.navigate(["/"]);
} catch (e) {
this.logService.error(e);
}
} }
} }

View File

@@ -1,72 +1,36 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate>
<div class="row justify-content-md-center mt-5"> <div class="row justify-content-md-center mt-5">
<div class="col-5"> <div class="col-5">
<p class="lead text-center mb-4">{{ "recoverAccountTwoStep" | i18n }}</p> <p class="lead text-center mb-4">{{'recoverAccountTwoStep' | i18n}}</p>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<p> <p>{{'recoverAccountTwoStepDesc' | i18n}}
{{ "recoverAccountTwoStepDesc" | i18n }} <a href="https://help.bitwarden.com/article/lost-two-step-device/" target="_blank"
<a rel="noopener">{{'learnMore' | i18n}}</a>
href="https://help.bitwarden.com/article/lost-two-step-device/"
target="_blank"
rel="noopener"
>{{ "learnMore" | i18n }}</a
>
</p> </p>
<div class="form-group"> <div class="form-group">
<label for="email">{{ "emailAddress" | i18n }}</label> <label for="email">{{'emailAddress' | i18n}}</label>
<input <input id="email" class="form-control" type="text" name="Email" [(ngModel)]="email" required
id="email" appAutofocus inputmode="email" appInputVerbatim="false">
class="form-control"
type="text"
name="Email"
[(ngModel)]="email"
required
appAutofocus
inputmode="email"
appInputVerbatim="false"
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="masterPassword">{{ "masterPass" | i18n }}</label> <label for="masterPassword">{{'masterPass' | i18n}}</label>
<input <input id="masterPassword" type="password" name="MasterPassword" class="form-control"
id="masterPassword" [(ngModel)]="masterPassword" required appInputVerbatim>
type="password"
name="MasterPassword"
class="form-control"
[(ngModel)]="masterPassword"
required
appInputVerbatim
/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="recoveryCode">{{ "recoveryCodeTitle" | i18n }}</label> <label for="recoveryCode">{{'recoveryCodeTitle' | i18n}}</label>
<input <input id="recoveryCode" class="text-monospace form-control" type="text" name="RecoveryCode"
id="recoveryCode" [(ngModel)]="recoveryCode" required appInputVerbatim>
class="text-monospace form-control"
type="text"
name="RecoveryCode"
[(ngModel)]="recoveryCode"
required
appInputVerbatim
/>
</div> </div>
<hr /> <hr>
<div class="d-flex"> <div class="d-flex">
<button <button type="submit" class="btn btn-primary btn-block btn-submit" [disabled]="form.loading">
type="submit" <span>{{'submit' | i18n}}</span>
class="btn btn-primary btn-block btn-submit" <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
[disabled]="form.loading"
>
<span>{{ "submit" | i18n }}</span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
<a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0"> <a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0">
{{ "cancel" | i18n }} {{'cancel' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,18 +1,18 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { ApiService } from "jslib-common/abstractions/api.service"; import { ToasterService } from 'angular2-toaster';
import { AuthService } from "jslib-common/abstractions/auth.service";
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { TwoFactorRecoveryRequest } from "jslib-common/models/request/twoFactorRecoveryRequest"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { TwoFactorRecoveryRequest } from 'jslib-common/models/request/twoFactorRecoveryRequest';
@Component({ @Component({
selector: "app-recover-two-factor", selector: 'app-recover-two-factor',
templateUrl: "recover-two-factor.component.html", templateUrl: 'recover-two-factor.component.html',
}) })
export class RecoverTwoFactorComponent { export class RecoverTwoFactorComponent {
email: string; email: string;
@@ -20,33 +20,21 @@ export class RecoverTwoFactorComponent {
recoveryCode: string; recoveryCode: string;
formPromise: Promise<any>; formPromise: Promise<any>;
constructor( constructor(private router: Router, private apiService: ApiService,
private router: Router, private toasterService: ToasterService, private i18nService: I18nService,
private apiService: ApiService, private cryptoService: CryptoService, private authService: AuthService) { }
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private cryptoService: CryptoService,
private authService: AuthService,
private logService: LogService
) {}
async submit() { async submit() {
try { try {
const request = new TwoFactorRecoveryRequest(); const request = new TwoFactorRecoveryRequest();
request.recoveryCode = this.recoveryCode.replace(/\s/g, "").toLowerCase(); request.recoveryCode = this.recoveryCode.replace(/\s/g, '').toLowerCase();
request.email = this.email.trim().toLowerCase(); request.email = this.email.trim().toLowerCase();
const key = await this.authService.makePreloginKey(this.masterPassword, request.email); const key = await this.authService.makePreloginKey(this.masterPassword, request.email);
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, key); request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, key);
this.formPromise = this.apiService.postTwoFactorRecover(request); this.formPromise = this.apiService.postTwoFactorRecover(request);
await this.formPromise; await this.formPromise;
this.platformUtilsService.showToast( this.toasterService.popAsync('success', null, this.i18nService.t('twoStepRecoverDisabled'));
"success", this.router.navigate(['/']);
null, } catch { }
this.i18nService.t("twoStepRecoverDisabled")
);
this.router.navigate(["/"]);
} catch (e) {
this.logService.error(e);
}
} }
} }

View File

@@ -3,11 +3,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-7"> <div class="col-7">
<img <img alt="Bitwarden" class="logo mb-2" src="../../images/register-layout/logo-horizontal-white.png">
alt="Bitwarden"
class="logo mb-2"
src="../../images/register-layout/logo-horizontal-white.png"
/>
</div> </div>
</div> </div>
</div> </div>
@@ -25,12 +21,12 @@
<figure> <figure>
<figcaption> <figcaption>
<cite> <cite>
<img src="../../images/register-layout/wired-logo.png" alt="Wired" /> <img src="../../images/register-layout/wired-logo.png" alt="Wired">
</cite> </cite>
</figcaption> </figcaption>
<blockquote> <blockquote>
"Bitwarden has become a popular choice among open-source software advocates. After "Bitwarden has become a popular choice among open-source software advocates. After using
using it for a few months, I can see why." - February 2020 it for a few months, I can see why." - February 2020
</blockquote> </blockquote>
</figure> </figure>
</div> </div>
@@ -42,168 +38,97 @@
</div> </div>
</div> </div>
</div> </div>
<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}">
<p class="lead text-center mb-4" *ngIf="!layout">{{ "createAccount" | i18n }}</p> <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 title="{{'createOrganizationStep1' | i18n}}" type="info"
title="{{ 'createOrganizationStep1' | i18n }}" icon="fa-thumb-tack" *ngIf="showCreateOrgMessage">
type="info" {{'createOrganizationCreatePersonalAccount' | i18n}}
icon="bwi bwi-thumb-tack"
*ngIf="showCreateOrgMessage"
>
{{ "createOrganizationCreatePersonalAccount" | i18n }}
</app-callout> </app-callout>
<div class="form-group"> <div class="form-group">
<label for="email">{{ "emailAddress" | i18n }}</label> <label for="email">{{'emailAddress' | i18n}}</label>
<input <input id="email" class="form-control" type="text" name="Email" [(ngModel)]="email"
id="email" required [appAutofocus]="email === ''" inputmode="email"
class="form-control" appInputVerbatim="false">
type="text" <small class="form-text text-muted">{{'emailAddressDesc' | i18n}}</small>
name="Email"
[(ngModel)]="email"
required
[appAutofocus]="email === ''"
inputmode="email"
appInputVerbatim="false"
/>
<small class="form-text text-muted">{{ "emailAddressDesc" | i18n }}</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="name">{{ "yourName" | i18n }}</label> <label for="name">{{'yourName' | i18n}}</label>
<input <input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name"
id="name" [appAutofocus]="email !== ''">
class="form-control" <small class="form-text text-muted">{{'yourNameDesc' | i18n}}</small>
type="text"
name="Name"
[(ngModel)]="name"
[appAutofocus]="email !== ''"
/>
<small class="form-text text-muted">{{ "yourNameDesc" | i18n }}</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<app-callout <app-callout type="info" [enforcedPolicyOptions]="enforcedPolicyOptions"
type="info" *ngIf="enforcedPolicyOptions">
[enforcedPolicyOptions]="enforcedPolicyOptions"
*ngIf="enforcedPolicyOptions"
>
</app-callout> </app-callout>
<label for="masterPassword">{{ "masterPass" | i18n }}</label> <label for="masterPassword">{{'masterPass' | i18n}}</label>
<div class="d-flex"> <div class="d-flex">
<div class="w-100"> <div class="w-100">
<input <input id="masterPassword" type="{{showPassword ? 'text' : 'password'}}"
id="masterPassword" name="MasterPassword" class="text-monospace form-control mb-1"
type="{{ showPassword ? 'text' : 'password' }}" [(ngModel)]="masterPassword" (input)="updatePasswordStrength()" required
name="MasterPassword" appInputVerbatim>
class="text-monospace form-control mb-1"
[(ngModel)]="masterPassword"
(input)="updatePasswordStrength()"
required
appInputVerbatim
/>
<app-password-strength [score]="masterPasswordScore" [showText]="true"> <app-password-strength [score]="masterPasswordScore" [showText]="true">
</app-password-strength> </app-password-strength>
</div> </div>
<div> <div>
<button <button type="button" class="ml-1 btn btn-link"
type="button" appA11yTitle="{{'toggleVisibility' | i18n}}"
class="ml-1 btn btn-link" (click)="togglePassword(false)">
appA11yTitle="{{ 'toggleVisibility' | i18n }}" <i class="fa fa-lg" aria-hidden="true"
(click)="togglePassword(false)" [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
>
<i
class="bwi bwi-lg"
aria-hidden="true"
[ngClass]="{
'bwi-eye': !showPassword,
'bwi-eye-slash': showPassword
}"
></i>
</button> </button>
<div class="progress-bar invisible"></div> <div class="progress-bar invisible"></div>
</div> </div>
</div> </div>
<small class="form-text text-muted">{{ "masterPassDesc" | i18n }}</small> <small class="form-text text-muted">{{'masterPassDesc' | i18n}}</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="masterPasswordRetype">{{ "reTypeMasterPass" | i18n }}</label> <label for="masterPasswordRetype">{{'reTypeMasterPass' | i18n}}</label>
<div class="d-flex"> <div class="d-flex">
<input <input id="masterPasswordRetype" type="{{showPassword ? 'text' : 'password'}}"
id="masterPasswordRetype" name="MasterPasswordRetype" class="text-monospace form-control"
type="{{ showPassword ? 'text' : 'password' }}" [(ngModel)]="confirmMasterPassword" required appInputVerbatim>
name="MasterPasswordRetype" <button type="button" class="ml-1 btn btn-link"
class="text-monospace form-control" appA11yTitle="{{'toggleVisibility' | i18n}}" (click)="togglePassword(true)">
[(ngModel)]="confirmMasterPassword" <i class="fa fa-lg" aria-hidden="true"
required [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
appInputVerbatim
/>
<button
type="button"
class="ml-1 btn btn-link"
appA11yTitle="{{ 'toggleVisibility' | i18n }}"
(click)="togglePassword(true)"
>
<i
class="bwi bwi-lg"
aria-hidden="true"
[ngClass]="{ 'bwi-eye': !showPassword, 'bwi-eye-slash': showPassword }"
></i>
</button> </button>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="hint">{{ "masterPassHint" | i18n }}</label> <label for="hint">{{'masterPassHint' | i18n}}</label>
<input <input id="hint" class="form-control" type="text" name="Hint" [(ngModel)]="hint">
id="hint" <small class="form-text text-muted">{{'masterPassHintDesc' | i18n}}</small>
class="form-control"
type="text"
name="Hint"
[(ngModel)]="hint"
/>
<small class="form-text text-muted">{{ "masterPassHintDesc" | i18n }}</small>
</div>
<div [hidden]="!showCaptcha()">
<iframe id="hcaptcha_iframe" height="80"></iframe>
</div> </div>
<div [hidden]="!showCaptcha()"><iframe id="hcaptcha_iframe" height="80"></iframe></div>
<div class="form-group" *ngIf="showTerms"> <div class="form-group" *ngIf="showTerms">
<div class="form-check"> <div class="form-check">
<input <input class="form-check-input" type="checkbox" id="acceptPolicies"
class="form-check-input" [(ngModel)]="acceptPolicies" name="AcceptPolicies">
type="checkbox"
id="acceptPolicies"
[(ngModel)]="acceptPolicies"
name="AcceptPolicies"
/>
<label class="form-check-label small text-muted" for="acceptPolicies"> <label class="form-check-label small text-muted" for="acceptPolicies">
{{ "acceptPolicies" | i18n }}<br /> {{'acceptPolicies' | i18n}}<br>
<a href="https://bitwarden.com/terms/" target="_blank" rel="noopener">{{ <a href="https://bitwarden.com/terms/" target="_blank"
"termsOfService" | i18n rel="noopener">{{'termsOfService' | i18n}}</a>,
}}</a <a href="https://bitwarden.com/privacy/" target="_blank"
>, rel="noopener">{{'privacyPolicy' | i18n}}</a>
<a href="https://bitwarden.com/privacy/" target="_blank" rel="noopener">{{
"privacyPolicy" | i18n
}}</a>
</label> </label>
</div> </div>
</div> </div>
<hr /> <hr>
<div class="d-flex mb-2"> <div class="d-flex mb-2">
<button <button type="submit" class="btn btn-primary btn-block btn-submit"
type="submit" [disabled]="form.loading">
class="btn btn-primary btn-block btn-submit" <span>{{'submit' | i18n}}</span>
[disabled]="form.loading" <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}"
> aria-hidden="true"></i>
<span>{{ "submit" | i18n }}</span>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
</button> </button>
<a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0"> <a routerLink="/" class="btn btn-outline-secondary btn-block ml-2 mt-0">
{{ "cancel" | i18n }} {{'cancel' | i18n}}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,81 +1,61 @@
import { Component } from "@angular/core"; import { Component } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import {
ActivatedRoute,
Router,
} from '@angular/router';
import { first } from "rxjs/operators"; import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ApiService } from "jslib-common/abstractions/api.service"; import { RegisterComponent as BaseRegisterComponent } from 'jslib-angular/components/register.component';
import { AuthService } from "jslib-common/abstractions/auth.service";
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service";
import { RegisterComponent as BaseRegisterComponent } from "jslib-angular/components/register.component"; import { MasterPasswordPolicyOptions } from 'jslib-common/models/domain/masterPasswordPolicyOptions';
import { Policy } from 'jslib-common/models/domain/policy';
import { MasterPasswordPolicyOptions } from "jslib-common/models/domain/masterPasswordPolicyOptions"; import { PolicyData } from 'jslib-common/models/data/policyData';
import { Policy } from "jslib-common/models/domain/policy"; import { ReferenceEventRequest } from 'jslib-common/models/request/referenceEventRequest';
import { PolicyData } from "jslib-common/models/data/policyData";
import { ReferenceEventRequest } from "jslib-common/models/request/referenceEventRequest";
@Component({ @Component({
selector: "app-register", selector: 'app-register',
templateUrl: "register.component.html", templateUrl: 'register.component.html',
}) })
export class RegisterComponent extends BaseRegisterComponent { export class RegisterComponent extends BaseRegisterComponent {
showCreateOrgMessage = false; showCreateOrgMessage = false;
layout = ""; layout = '';
enforcedPolicyOptions: MasterPasswordPolicyOptions; enforcedPolicyOptions: MasterPasswordPolicyOptions;
private policies: Policy[]; private policies: Policy[];
constructor( constructor(authService: AuthService, router: Router,
authService: AuthService, i18nService: I18nService, cryptoService: CryptoService,
router: Router, apiService: ApiService, private route: ActivatedRoute,
i18nService: I18nService, stateService: StateService, platformUtilsService: PlatformUtilsService,
cryptoService: CryptoService, passwordGenerationService: PasswordGenerationService, private policyService: PolicyService,
apiService: ApiService, environmentService: EnvironmentService) {
private route: ActivatedRoute, super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService,
stateService: StateService, passwordGenerationService, environmentService);
platformUtilsService: PlatformUtilsService,
passwordGenerationService: PasswordGenerationService,
private policyService: PolicyService,
environmentService: EnvironmentService,
logService: LogService
) {
super(
authService,
router,
i18nService,
cryptoService,
apiService,
stateService,
platformUtilsService,
passwordGenerationService,
environmentService,
logService
);
} }
async ngOnInit() { async ngOnInit() {
this.route.queryParams.pipe(first()).subscribe((qParams) => { const queryParamsSub = this.route.queryParams.subscribe(qParams => {
this.referenceData = new ReferenceEventRequest(); this.referenceData = new ReferenceEventRequest();
if (qParams.email != null && qParams.email.indexOf("@") > -1) { if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email; this.email = qParams.email;
} }
if (qParams.premium != null) { if (qParams.premium != null) {
this.stateService.setLoginRedirect({ route: "/settings/premium" }); this.stateService.save('loginRedirect', { route: '/settings/premium' });
} else if (qParams.org != null) { } else if (qParams.org != null) {
this.showCreateOrgMessage = true; this.showCreateOrgMessage = true;
this.referenceData.flow = qParams.org; this.referenceData.flow = qParams.org;
this.stateService.setLoginRedirect({ this.stateService.save('loginRedirect',
route: "/settings/create-organization", { route: '/settings/create-organization', qParams: { plan: qParams.org } });
qParams: { plan: qParams.org },
});
} }
if (qParams.layout != null) { if (qParams.layout != null) {
this.layout = this.referenceData.layout = qParams.layout; this.layout = this.referenceData.layout = qParams.layout;
@@ -83,65 +63,40 @@ export class RegisterComponent extends BaseRegisterComponent {
if (qParams.reference != null) { if (qParams.reference != null) {
this.referenceData.id = qParams.reference; this.referenceData.id = qParams.reference;
} else { } else {
this.referenceData.id = ("; " + document.cookie) this.referenceData.id = ('; ' + document.cookie).split('; reference=').pop().split(';').shift();
.split("; reference=")
.pop()
.split(";")
.shift();
} }
// Are they coming from an email for sponsoring a families organization if (this.referenceData.id === '') {
if (qParams.sponsorshipToken != null) {
// After logging in redirect them to setup the families sponsorship
this.stateService.setLoginRedirect({
route: "/setup/families-for-enterprise",
qParams: { token: qParams.sponsorshipToken },
});
}
if (this.referenceData.id === "") {
this.referenceData.id = null; this.referenceData.id = null;
} }
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
}); });
const invite = await this.stateService.getOrganizationInvitation(); const invite = await this.stateService.get<any>('orgInvitation');
if (invite != null) { if (invite != null) {
try { try {
const policies = await this.apiService.getPoliciesByToken( const policies = await this.apiService.getPoliciesByToken(invite.organizationId, invite.token,
invite.organizationId, invite.email, invite.organizationUserId);
invite.token,
invite.email,
invite.organizationUserId
);
if (policies.data != null) { if (policies.data != null) {
const policiesData = policies.data.map((p) => new PolicyData(p)); const policiesData = policies.data.map(p => new PolicyData(p));
this.policies = policiesData.map((p) => new Policy(p)); this.policies = policiesData.map(p => new Policy(p));
}
} catch (e) {
this.logService.error(e);
} }
} catch { }
} }
if (this.policies != null) { if (this.policies != null) {
this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions( this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions(this.policies);
this.policies
);
} }
await super.ngOnInit(); await super.ngOnInit();
} }
async submit() { async submit() {
if ( if (this.enforcedPolicyOptions != null &&
this.enforcedPolicyOptions != null && !this.policyService.evaluateMasterPassword(this.masterPasswordScore, this.masterPassword,
!this.policyService.evaluateMasterPassword( this.enforcedPolicyOptions)) {
this.masterPasswordScore, this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.masterPassword, this.i18nService.t('masterPasswordPolicyRequirementsNotMet'));
this.enforcedPolicyOptions
)
) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("masterPasswordPolicyRequirementsNotMet")
);
return; return;
} }

View File

@@ -1,55 +0,0 @@
<div class="mt-5 d-flex justify-content-center" *ngIf="loading">
<div>
<img class="mb-4 logo logo-themed" alt="Bitwarden" />
<p class="text-center">
<i
class="bwi bwi-spinner bwi-spin bwi-2x text-muted"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
></i>
<span class="sr-only">{{ "loading" | i18n }}</span>
</p>
</div>
</div>
<div class="container" *ngIf="!loading">
<div class="row justify-content-md-center mt-5">
<div class="col-5">
<p class="lead text-center mb-4">{{ "removeMasterPassword" | i18n }}</p>
<hr />
<div class="card d-block">
<div class="card-body">
<p>{{ "convertOrganizationEncryptionDesc" | i18n: organization.name }}</p>
<button
type="button"
class="btn btn-primary btn-block"
(click)="convert()"
[disabled]="actionPromise"
>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
*ngIf="continuing"
></i>
{{ "removeMasterPassword" | i18n }}
</button>
<button
type="button"
class="btn btn-outline-secondary btn-block"
(click)="leave()"
[disabled]="actionPromise"
>
<i
class="bwi bwi-spinner bwi-spin"
title="{{ 'loading' | i18n }}"
aria-hidden="true"
*ngIf="leaving"
></i>
{{ "leaveOrganization" | i18n }}
</button>
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,9 +0,0 @@
import { Component } from "@angular/core";
import { RemovePasswordComponent as BaseRemovePasswordComponent } from "jslib-angular/components/remove-password.component";
@Component({
selector: "app-remove-password",
templateUrl: "remove-password.component.html",
})
export class RemovePasswordComponent extends BaseRemovePasswordComponent {}

Some files were not shown because too many files have changed in this diff Show More