]>
Commit | Line | Data |
---|---|---|
92b9d60c | 1 | import { Component, Input } from '@angular/core' |
67ed6552 | 2 | import { AuthService, ConfirmService, Notifier, RedirectService, User, UserService } from '@app/core' |
92b9d60c C |
3 | |
4 | @Component({ | |
5 | selector: 'my-account-danger-zone', | |
6 | templateUrl: './my-account-danger-zone.component.html', | |
7 | styleUrls: [ './my-account-danger-zone.component.scss' ] | |
8 | }) | |
9 | export class MyAccountDangerZoneComponent { | |
10 | @Input() user: User = null | |
11 | ||
12 | constructor ( | |
13 | private authService: AuthService, | |
f8b2c1b4 | 14 | private notifier: Notifier, |
92b9d60c C |
15 | private userService: UserService, |
16 | private confirmService: ConfirmService, | |
66357162 | 17 | private redirectService: RedirectService |
9df52d66 | 18 | ) { } |
92b9d60c C |
19 | |
20 | async deleteMe () { | |
21 | const res = await this.confirmService.confirmWithInput( | |
4edee628 C |
22 | $localize`Are you sure you want to delete your account?` + |
23 | '<br /><br />' + | |
24 | // eslint-disable-next-line max-len | |
25 | $localize`This will delete all your data, including channels, videos, comments and you won't be able to create another user on this instance with "${this.user.username}" username.` + | |
26 | '<br /><br />' + | |
27 | $localize`Content cached by other servers and other third-parties might make longer to be deleted.`, | |
28 | ||
66357162 | 29 | $localize`Type your username to confirm`, |
92b9d60c | 30 | this.user.username, |
66357162 C |
31 | $localize`Delete your account`, |
32 | $localize`Delete my account` | |
92b9d60c C |
33 | ) |
34 | if (res === false) return | |
35 | ||
1378c0d3 C |
36 | this.userService.deleteMe() |
37 | .subscribe({ | |
38 | next: () => { | |
39 | this.notifier.success($localize`Your account is deleted.`) | |
92b9d60c | 40 | |
1378c0d3 C |
41 | this.authService.logout() |
42 | this.redirectService.redirectToHomepage() | |
43 | }, | |
92b9d60c | 44 | |
1378c0d3 C |
45 | error: err => this.notifier.error(err.message) |
46 | }) | |
92b9d60c C |
47 | } |
48 | } |