From 2166c058f34dff6f91566930d12448805d829de7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Oct 2022 14:23:42 +0200 Subject: Allow admins to disable two factor auth --- .../my-account-two-factor/index.ts | 1 - .../my-account-two-factor-button.component.ts | 2 +- .../my-account-two-factor.component.ts | 2 +- .../my-account-two-factor/two-factor.service.ts | 52 ---------------------- client/src/app/+my-account/my-account.module.ts | 12 ++--- 5 files changed, 6 insertions(+), 63 deletions(-) delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts (limited to 'client/src/app/+my-account') diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts index ef83009a5..cc774bde3 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/index.ts @@ -1,3 +1,2 @@ export * from './my-account-two-factor-button.component' export * from './my-account-two-factor.component' -export * from './two-factor.service' diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts index 03b00e933..97ffb6013 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor-button.component.ts @@ -1,7 +1,7 @@ import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' import { AuthService, ConfirmService, Notifier, User } from '@app/core' -import { TwoFactorService } from './two-factor.service' +import { TwoFactorService } from '@app/shared/shared-users' @Component({ selector: 'my-account-two-factor-button', diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts index e4d4188f7..259090d64 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.ts @@ -4,7 +4,7 @@ import { Router } from '@angular/router' import { AuthService, Notifier, User } from '@app/core' import { USER_EXISTING_PASSWORD_VALIDATOR, USER_OTP_TOKEN_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactiveService } from '@app/shared/shared-forms' -import { TwoFactorService } from './two-factor.service' +import { TwoFactorService } from '@app/shared/shared-users' @Component({ selector: 'my-account-two-factor', diff --git a/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts b/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts deleted file mode 100644 index c0e5ac492..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-two-factor/two-factor.service.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { catchError } from 'rxjs/operators' -import { HttpClient } from '@angular/common/http' -import { Injectable } from '@angular/core' -import { RestExtractor, UserService } from '@app/core' -import { TwoFactorEnableResult } from '@shared/models' - -@Injectable() -export class TwoFactorService { - constructor ( - private authHttp: HttpClient, - private restExtractor: RestExtractor - ) { } - - // --------------------------------------------------------------------------- - - requestTwoFactor (options: { - userId: number - currentPassword: string - }) { - const { userId, currentPassword } = options - - const url = UserService.BASE_USERS_URL + userId + '/two-factor/request' - - return this.authHttp.post(url, { currentPassword }) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } - - confirmTwoFactorRequest (options: { - userId: number - requestToken: string - otpToken: string - }) { - const { userId, requestToken, otpToken } = options - - const url = UserService.BASE_USERS_URL + userId + '/two-factor/confirm-request' - - return this.authHttp.post(url, { requestToken, otpToken }) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } - - disableTwoFactor (options: { - userId: number - currentPassword: string - }) { - const { userId, currentPassword } = options - - const url = UserService.BASE_USERS_URL + userId + '/two-factor/disable' - - return this.authHttp.post(url, { currentPassword }) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } -} diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index f5beaa4db..84b057647 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts @@ -11,6 +11,7 @@ import { SharedMainModule } from '@app/shared/shared-main' import { SharedModerationModule } from '@app/shared/shared-moderation' import { SharedShareModal } from '@app/shared/shared-share-modal' import { SharedUserInterfaceSettingsModule } from '@app/shared/shared-user-settings' +import { SharedUsersModule } from '@app/shared/shared-users' import { SharedActorImageModule } from '../shared/shared-actor-image/shared-actor-image.module' import { MyAccountAbusesListComponent } from './my-account-abuses/my-account-abuses-list.component' import { MyAccountApplicationsComponent } from './my-account-applications/my-account-applications.component' @@ -24,11 +25,7 @@ import { MyAccountDangerZoneComponent } from './my-account-settings/my-account-d import { MyAccountNotificationPreferencesComponent } from './my-account-settings/my-account-notification-preferences' import { MyAccountProfileComponent } from './my-account-settings/my-account-profile/my-account-profile.component' import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component' -import { - MyAccountTwoFactorButtonComponent, - MyAccountTwoFactorComponent, - TwoFactorService -} from './my-account-settings/my-account-two-factor' +import { MyAccountTwoFactorButtonComponent, MyAccountTwoFactorComponent } from './my-account-settings/my-account-two-factor' import { MyAccountComponent } from './my-account.component' @NgModule({ @@ -44,6 +41,7 @@ import { MyAccountComponent } from './my-account.component' SharedFormModule, SharedModerationModule, SharedUserInterfaceSettingsModule, + SharedUsersModule, SharedGlobalIconModule, SharedAbuseListModule, SharedShareModal, @@ -74,9 +72,7 @@ import { MyAccountComponent } from './my-account.component' MyAccountComponent ], - providers: [ - TwoFactorService - ] + providers: [] }) export class MyAccountModule { } -- cgit v1.2.3