1 import { Component, Input } from '@angular/core'
2 import { Notifier } from '@app/core'
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'
9 selector: 'my-account-danger-zone',
10 templateUrl: './my-account-danger-zone.component.html',
11 styleUrls: [ './my-account-danger-zone.component.scss' ]
13 export class MyAccountDangerZoneComponent {
14 @Input() user: User = null
17 private authService: AuthService,
18 private notifier: Notifier,
19 private userService: UserService,
20 private confirmService: ConfirmService,
21 private redirectService: RedirectService,
26 const res = await this.confirmService.confirmWithInput(
27 this.i18n('Are you sure you want to delete your account? This will delete all your data, including channels, videos and comments. Content cached by other servers and other third-parties might make longer to be deleted.'),
28 this.i18n('Type your username to confirm'),
30 this.i18n('Delete your account'),
31 this.i18n('Delete my account')
33 if (res === false) return
35 this.userService.deleteMe().subscribe(
37 this.notifier.success(this.i18n('Your account is deleted.'))
39 this.authService.logout()
40 this.redirectService.redirectToHomepage()
43 err => this.notifier.error(err.message)