summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/mixins/recaptcha_dialog_implementor.js
blob: ef70f9432e3394d3d812221b44e6501272276c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import RecaptchaDialog from '../components/recaptcha_dialog.vue';

export default {
  data() {
    return {
      showRecaptcha: false,
      recaptchaHTML: '',
    };
  },

  components: {
    RecaptchaDialog,
  },

  methods: {
    openRecaptcha() {
      this.showRecaptcha = true;
    },

    closeRecaptcha() {
      this.showRecaptcha = false;
    },

    checkForSpam(data) {
      if (!data.recaptcha_html) return data;

      this.recaptchaHTML = data.recaptcha_html;

      const spamError = new Error(data.error_message);
      spamError.name = 'SpamError';
      spamError.message = 'SpamError';

      throw spamError;
    },
  },
};