<commit_before><template>
  <div v-if="name !== ''" class="row justify-center full-width">
    <div class="col-12">
      <k-block 
        color="red" 
        :title="$t('KAccountDZ.BLOCK_TITLE')"
        :text="$t('KAccountDZ.BLOCK_TEXT')"
        :action="$t('KAccountDZ.BLOCK_ACTION')"
        @action-triggered="onDeleteClicked" />
    </div>
  </div>
</template>

<script>
import { Dialog } from 'quasar'
import mixins from '../../mixins'

export default {
  name: 'k-account-dz',
  mixins: [
    mixins.service
  ],
  props: {
    name: {
      type: String,
      default: ''
    }
  },
  methods: {
    loadService () {
      return this._service = this.$api.getService('users')
    },
    onDeleteClicked () {
      Dialog.create({
        title: this.$t('KAccountDZ.DIALOG_TITLE'),
        form: {
          confirm: {
            type: 'text',
            model: '',
            label: this.$t('KAccountDZ.DIALOG_HELPER')
          }
        },
        buttons: [
          {
            label: 'Ok',
            preventClose: true,
            handler: (data, close) => {
              if (data.confirm === this.name) {
                close(() => { 
                  this.loadService().remove(this.objectId)
                  .then(() => {
                    this.$router.push({name: 'logout'})
                  })
                })
              }
            }
          },
          'Cancel'
        ]
      })
    }
  },
  created () {
    // Load the components
    this.$options.components['k-block'] = this.$load('frame/KBlock')
  }
}
</script><commit_msg>Forced to logout when deleting the account<commit_after><template>
  <div v-if="name !== ''" class="row justify-center full-width">
    <div class="col-12">
      <k-block 
        color="red" 
        :title="$t('KAccountDZ.BLOCK_TITLE')"
        :text="$t('KAccountDZ.BLOCK_TEXT')"
        :action="$t('KAccountDZ.BLOCK_ACTION')"
        @action-triggered="onDeleteClicked" />
    </div>
  </div>
</template>

<script>
import { Dialog } from 'quasar'
import mixins from '../../mixins'

export default {
  name: 'k-account-dz',
  mixins: [
    mixins.service
  ],
  props: {
    name: {
      type: String,
      default: ''
    }
  },
  methods: {
    loadService () {
      return this._service = this.$api.getService('users')
    },
    onDeleteClicked () {
      Dialog.create({
        title: this.$t('KAccountDZ.DIALOG_TITLE'),
        form: {
          confirm: {
            type: 'text',
            model: '',
            label: this.$t('KAccountDZ.DIALOG_HELPER')
          }
        },
        buttons: [
          {
            label: 'Ok',
            preventClose: true,
            handler: (data, close) => {
              if (data.confirm === this.name) {
                close(() => { 
                  this.loadService().remove(this.objectId)
                  // Force to logout even if the triggered hook chain failed
                  this.$router.push({name: 'logout'})
                })
              }
            }
          },
          'Cancel'
        ]
      })
    }
  },
  created () {
    // Load the components
    this.$options.components['k-block'] = this.$load('frame/KBlock')
  }
}
</script>
{'fraction_non_alphanumeric': 0.16329704510108864, 'fraction_numerical': 0.001244167962674961, 'mean_word_length': 1.5748598879103282, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2225587', 'n_tokens_mistral': 1020, 'n_tokens_neox': 995, 'n_words': 168}