diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts index fab9cfc4b..0e2bf51e8 100644 --- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts +++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts @@ -7,7 +7,7 @@ import { FROM_NAME_VALIDATOR, SUBJECT_VALIDATOR } from '@app/shared/form-validators/instance-validators' -import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { InstanceService } from '@app/shared/shared-instance' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -32,7 +32,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit { private serverConfig: HTMLServerConfig constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private router: Router, private modalService: NgbModal, private instanceService: InstanceService, diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 545e37857..168f4702c 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -18,15 +18,15 @@ import { MAX_INSTANCE_LIVES_VALIDATOR, MAX_LIVE_DURATION_VALIDATOR, MAX_USER_LIVES_VALIDATOR, + MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR, SEARCH_INDEX_URL_VALIDATOR, SERVICES_TWITTER_USERNAME_VALIDATOR, SIGNUP_LIMIT_VALIDATOR, SIGNUP_MINIMUM_AGE_VALIDATOR, - TRANSCODING_THREADS_VALIDATOR, - MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR + TRANSCODING_THREADS_VALIDATOR } from '@app/shared/form-validators/custom-config-validators' import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' -import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { CustomPageService } from '@app/shared/shared-main/custom-page' import { CustomConfig, CustomPage, HTMLServerConfig } from '@shared/models' import { EditConfigurationService } from './edit-configuration.service' @@ -52,9 +52,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { categoryItems: SelectOptionsItem[] = [] constructor ( + protected formReactiveService: FormReactiveService, private router: Router, private route: ActivatedRoute, - protected formValidatorService: FormValidatorService, private notifier: Notifier, private configService: ConfigService, private customPage: CustomPageService, diff --git a/client/src/app/+admin/follows/following-list/follow-modal.component.ts b/client/src/app/+admin/follows/following-list/follow-modal.component.ts index 07cc75d77..8f74e82a6 100644 --- a/client/src/app/+admin/follows/following-list/follow-modal.component.ts +++ b/client/src/app/+admin/follows/following-list/follow-modal.component.ts @@ -2,7 +2,7 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/cor import { Notifier } from '@app/core' import { prepareIcu } from '@app/helpers' import { splitAndGetNotEmpty, UNIQUE_HOSTS_OR_HANDLE_VALIDATOR } from '@app/shared/form-validators/host-validators' -import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { InstanceFollowService } from '@app/shared/shared-instance' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -22,7 +22,7 @@ export class FollowModalComponent extends FormReactive implements OnInit { private openedModal: NgbModalRef constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private modalService: NgbModal, private followService: InstanceFollowService, private notifier: Notifier diff --git a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts index 1713e06ce..0627aa887 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts @@ -12,7 +12,7 @@ import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' -import { FormValidatorService } from '@app/shared/shared-forms' +import { FormReactiveService } from '@app/shared/shared-forms' import { UserAdminService } from '@app/shared/shared-users' import { UserCreate, UserRole } from '@shared/models' import { UserEdit } from './user-edit' @@ -27,7 +27,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { constructor ( protected serverService: ServerService, - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected configService: ConfigService, protected screenService: ScreenService, protected auth: AuthService, diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.component.html b/client/src/app/+admin/overview/users/user-edit/user-edit.component.html index da5879a36..e51ccf808 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.component.html +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.component.html @@ -204,7 +204,7 @@ -
+
@@ -213,7 +213,7 @@
-
+
@@ -222,6 +222,11 @@
+ +
+ + +
diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss b/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss index 68fa1215f..698628149 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.component.scss @@ -48,17 +48,13 @@ my-user-real-quota-info { } .danger-zone { - .reset-password-email { - margin-bottom: 30px; + button { + @include peertube-button; + @include danger-button; + @include disable-outline; - button { - @include peertube-button; - @include danger-button; - @include disable-outline; - - display: block; - margin-top: 0; - } + display: block; + margin-top: 0; } } diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.ts b/client/src/app/+admin/overview/users/user-edit/user-edit.ts index 6dae4110d..21e9629ab 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-edit.ts @@ -60,10 +60,22 @@ export abstract class UserEdit extends FormReactive implements OnInit { ] } + displayDangerZone () { + if (this.isCreation()) return false + if (this.user?.pluginAuth) return false + if (this.auth.getUser().id === this.user.id) return false + + return true + } + resetPassword () { return } + disableTwoFactorAuth () { + return + } + getUserVideoQuota () { return this.form.value['videoQuota'] } diff --git a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts index 8999d1f00..d6616e077 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core' import { Notifier } from '@app/core' import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' -import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { UserAdminService } from '@app/shared/shared-users' import { UserUpdate } from '@shared/models' @@ -18,7 +18,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit { @Input() userId: number constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private notifier: Notifier, private userAdminService: UserAdminService ) { diff --git a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts index bab288a67..71212b19c 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts @@ -9,8 +9,8 @@ import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' -import { FormValidatorService } from '@app/shared/shared-forms' -import { UserAdminService } from '@app/shared/shared-users' +import { FormReactiveService } from '@app/shared/shared-forms' +import { TwoFactorService, UserAdminService } from '@app/shared/shared-users' import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' import { UserEdit } from './user-edit' @@ -25,7 +25,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { private paramsSub: Subscription constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, protected serverService: ServerService, protected configService: ConfigService, protected screenService: ScreenService, @@ -34,6 +34,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { private router: Router, private notifier: Notifier, private userService: UserService, + private twoFactorService: TwoFactorService, private userAdminService: UserAdminService ) { super() @@ -120,12 +121,24 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { this.notifier.success($localize`An email asking for password reset has been sent to ${this.user.username}.`) }, - error: err => { - this.error = err.message - } + error: err => this.notifier.error(err.message) }) } + disableTwoFactorAuth () { + this.twoFactorService.disableTwoFactor({ userId: this.user.id }) + .subscribe({ + next: () => { + this.user.twoFactorEnabled = false + + this.notifier.success($localize`Two factor authentication of ${this.user.username} disabled.`) + }, + + error: err => this.notifier.error(err.message) + }) + + } + private onUserFetched (userJson: UserType) { this.user = new User(userJson) diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.scss b/client/src/app/+admin/overview/users/user-list/user-list.component.scss index 3c775cac5..23e0d29ee 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.scss +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.scss @@ -1,6 +1,6 @@ @use '_variables' as *; @use '_mixins' as *; -@use '~bootstrap/scss/functions' as *; +@use 'bootstrap/scss/functions' as *; .add-button { @include create-button; diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts index ec02cfcd9..b1a41567e 100644 --- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts +++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts @@ -4,7 +4,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { HooksService, Notifier, PluginService } from '@app/core' import { BuildFormArgument } from '@app/shared/form-validators' -import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models' import { PluginApiService } from '../shared/plugin-api.service' @@ -22,7 +22,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit private npmName: string constructor ( - protected formValidatorService: FormValidatorService, + protected formReactiveService: FormReactiveService, private pluginService: PluginService, private pluginAPIService: PluginApiService, private notifier: Notifier, diff --git a/client/src/app/+login/login.component.html b/client/src/app/+login/login.component.html index f3a2476f9..49b443a20 100644 --- a/client/src/app/+login/login.component.html +++ b/client/src/app/+login/login.component.html @@ -39,34 +39,48 @@