1+ import { localStorageAvailable } from '../utils/local-storage' ;
2+
13export default function ( app ) {
24 app . component ( 'accountDeleteModal' , {
35 bindings : {
@@ -11,8 +13,14 @@ export default function(app) {
1113 public submitting = false ;
1214 public succeeded = false ;
1315
14- static $inject = [ '$http' , '$scope' , 'authService' , 'peopleApi' ] ;
15- constructor ( public $http , public $scope , public authService , public peopleApi ) { }
16+ static $inject = [
17+ '$http' , '$location' , '$scope' , '$window' ,
18+ 'authService' , 'notificationService' , 'peopleApi' ,
19+ ] ;
20+ constructor (
21+ public $http , public $location , public $scope , public $window ,
22+ public authService , public notificationService , public peopleApi ,
23+ ) { }
1624
1725 public hasError ( field ) {
1826 const form = this . $scope . accountDeleteForm ;
@@ -26,6 +34,13 @@ export default function(app) {
2634 this . peopleApi . deleteAccount ( this . authService . user . id )
2735 . then ( ( ) => {
2836 this . succeeded = true ;
37+ this . authService . logout ( ) ;
38+ if ( localStorageAvailable ) this . $window . localStorage . clear ( ) ;
39+ this . notificationService . notifications . push ( {
40+ type : 'info' ,
41+ message : 'Your account has been successfully deleted.' ,
42+ } ) ;
43+ this . $location . url ( '/' ) ;
2944 return this . close ( ) ;
3045 } )
3146 . catch ( error => this . error = error )
0 commit comments