From 92b9d60c00432c58d6184f3683bdb14a0300a3c6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Aug 2018 10:55:27 +0200 Subject: Add ability to delete our account --- .../my-account-danger-zone/index.ts | 1 + .../my-account-danger-zone.component.html | 5 +++ .../my-account-danger-zone.component.scss | 11 ++++++ .../my-account-danger-zone.component.ts | 46 ++++++++++++++++++++++ .../my-account-settings.component.html | 3 ++ client/src/app/+my-account/my-account.module.ts | 4 +- 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 client/src/app/+my-account/my-account-settings/my-account-danger-zone/index.ts create mode 100644 client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.html create mode 100644 client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.scss create mode 100644 client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts (limited to 'client/src/app/+my-account') diff --git a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/index.ts b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/index.ts new file mode 100644 index 000000000..88a39bb97 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/index.ts @@ -0,0 +1 @@ +export * from './my-account-danger-zone.component' diff --git a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.html b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.html new file mode 100644 index 000000000..8caff972f --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.html @@ -0,0 +1,5 @@ +
+

Once you delete your account, there is no going back. Please be certain.

+ + +
\ No newline at end of file diff --git a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.scss b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.scss new file mode 100644 index 000000000..0ca310468 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.scss @@ -0,0 +1,11 @@ +@import '_variables'; +@import '_mixins'; + +.delete-me { + font-size: 15px; + + button { + @include peertube-button; + @include grey-button; + } +} \ No newline at end of file diff --git a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts new file mode 100644 index 000000000..63a121f64 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts @@ -0,0 +1,46 @@ +import { Component, Input } from '@angular/core' +import { NotificationsService } from 'angular2-notifications' +import { AuthService, ConfirmService, RedirectService } from '../../../core' +import { UserService } from '../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { User } from '@app/shared' + +@Component({ + selector: 'my-account-danger-zone', + templateUrl: './my-account-danger-zone.component.html', + styleUrls: [ './my-account-danger-zone.component.scss' ] +}) +export class MyAccountDangerZoneComponent { + @Input() user: User = null + + constructor ( + private authService: AuthService, + private notificationsService: NotificationsService, + private userService: UserService, + private confirmService: ConfirmService, + private redirectService: RedirectService, + private i18n: I18n + ) { } + + async deleteMe () { + const res = await this.confirmService.confirmWithInput( + this.i18n('Are you sure you want to delete your account? This will delete all you data, including channels, videos etc.'), + this.i18n('Type your username to confirm'), + this.user.username, + this.i18n('Delete your account'), + this.i18n('Delete my account') + ) + if (res === false) return + + this.userService.deleteMe().subscribe( + () => { + this.notificationsService.success(this.i18n('Success'), this.i18n('Your account is deleted.')) + + this.authService.logout() + this.redirectService.redirectToHomepage() + }, + + err => this.notificationsService.error(this.i18n('Error'), err.message) + ) + } +} diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-settings.component.html index ff08cb777..c7e23cd1f 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.html +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.html @@ -14,3 +14,6 @@
Video settings
+ +
Danger zone
+ \ No newline at end of file diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index 5403ab649..29b49e8d9 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts @@ -13,6 +13,7 @@ import { MyAccountVideoChannelCreateComponent } from '@app/+my-account/my-accoun import { MyAccountVideoChannelUpdateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-update.component' import { ActorAvatarInfoComponent } from '@app/+my-account/shared/actor-avatar-info.component' import { MyAccountVideoImportsComponent } from '@app/+my-account/my-account-video-imports/my-account-video-imports.component' +import { MyAccountDangerZoneComponent } from '@app/+my-account/my-account-settings/my-account-danger-zone' @NgModule({ imports: [ @@ -32,7 +33,8 @@ import { MyAccountVideoImportsComponent } from '@app/+my-account/my-account-vide MyAccountVideoChannelCreateComponent, MyAccountVideoChannelUpdateComponent, ActorAvatarInfoComponent, - MyAccountVideoImportsComponent + MyAccountVideoImportsComponent, + MyAccountDangerZoneComponent ], exports: [ -- cgit v1.2.3