summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/mixins/recaptcha_modal_implementor.js
blob: ff1f565e79ae7da1b4dd274f8d8d9165aaa0c5ae (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 recaptchaModal from '../components/recaptcha_modal.vue';

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

  components: {
    recaptchaModal,
  },

  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;
    },
  },
};