+ this.routeSub = this.route.params
+ .pipe(
+ map(params => params[ 'accountId' ]),
+ distinctUntilChanged(),
+ switchMap(accountId => this.accountService.getAccount(accountId)),
+ tap(account => this.getUserIfNeeded(account)),
+ catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
+ )
+ .subscribe(
+ account => this.account = account,
+
+ err => this.notifier.error(err.message)
+ )
+ }
+
+ ngOnDestroy () {
+ if (this.routeSub) this.routeSub.unsubscribe()
+ }
+
+ onUserChanged () {
+ this.getUserIfNeeded(this.account)
+ }
+
+ onUserDeleted () {
+ this.redirectService.redirectToHomepage()
+ }
+
+ activateCopiedMessage () {
+ this.notifier.success(this.i18n('Username copied'))
+ }
+
+ private getUserIfNeeded (account: Account) {
+ if (!account.userId) return
+ if (!this.authService.isLoggedIn()) return
+
+ const user = this.authService.getUser()
+ if (user.hasRight(UserRight.MANAGE_USERS)) {
+ this.userService.getUser(account.userId)
+ .subscribe(
+ user => this.user = user,