diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-danger-zone')
4 files changed, 63 insertions, 0 deletions
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 @@ | |||
1 | <div class="delete-me"> | ||
2 | <p>Once you delete your account, there is no going back. Please be certain.</p> | ||
3 | |||
4 | <button (click)="deleteMe()">Delete your account</button> | ||
5 | </div> \ 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 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .delete-me { | ||
5 | font-size: 15px; | ||
6 | |||
7 | button { | ||
8 | @include peertube-button; | ||
9 | @include grey-button; | ||
10 | } | ||
11 | } \ 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 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { AuthService, ConfirmService, RedirectService } from '../../../core' | ||
4 | import { UserService } from '../../../shared' | ||
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | import { User } from '@app/shared' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-account-danger-zone', | ||
10 | templateUrl: './my-account-danger-zone.component.html', | ||
11 | styleUrls: [ './my-account-danger-zone.component.scss' ] | ||
12 | }) | ||
13 | export class MyAccountDangerZoneComponent { | ||
14 | @Input() user: User = null | ||
15 | |||
16 | constructor ( | ||
17 | private authService: AuthService, | ||
18 | private notificationsService: NotificationsService, | ||
19 | private userService: UserService, | ||
20 | private confirmService: ConfirmService, | ||
21 | private redirectService: RedirectService, | ||
22 | private i18n: I18n | ||
23 | ) { } | ||
24 | |||
25 | async deleteMe () { | ||
26 | const res = await this.confirmService.confirmWithInput( | ||
27 | this.i18n('Are you sure you want to delete your account? This will delete all you data, including channels, videos etc.'), | ||
28 | this.i18n('Type your username to confirm'), | ||
29 | this.user.username, | ||
30 | this.i18n('Delete your account'), | ||
31 | this.i18n('Delete my account') | ||
32 | ) | ||
33 | if (res === false) return | ||
34 | |||
35 | this.userService.deleteMe().subscribe( | ||
36 | () => { | ||
37 | this.notificationsService.success(this.i18n('Success'), this.i18n('Your account is deleted.')) | ||
38 | |||
39 | this.authService.logout() | ||
40 | this.redirectService.redirectToHomepage() | ||
41 | }, | ||
42 | |||
43 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
44 | ) | ||
45 | } | ||
46 | } | ||