<commit_before>import { Component } from '@angular/core';

import { Client } from '../../../services/api';
import { OverlayModalService } from '../../../services/ux/overlay-modal';
import { ConfirmPasswordModalComponent } from '../../modals/confirm-password/modal.component';

@Component({
  moduleId: module.id,
  selector: 'm-settings--two-factor',
  inputs: ['object'],
  templateUrl: 'two-factor.component.html'
})

export class SettingsTwoFactorComponent {

  minds: Minds;
  telno: number;
  secret;
  waitingForCheck: boolean = false;
  sendingSms: boolean = false;
  object: any;

  inProgress: boolean = false;
  error: string = '';

  constructor(public client: Client, private overlayModal: OverlayModalService) {
    this.minds = window.Minds;
    this.load();
  }

  load() {
    this.inProgress = true;
    this.client.get('api/v1/twofactor')
      .then((response: any) => {
        if (response.telno)
          this.telno = response.telno;
        this.inProgress = false;
      });
  }

  setup(smsNumber: any) {
    this.telno = smsNumber;
    this.waitingForCheck = true;
    this.sendingSms = true;
    this.error = '';
    this.client.post('api/v1/twofactor/setup', { tel: smsNumber })
      .then((response: any) => {
        this.secret = response.secret;
        this.sendingSms = false;
      })
      .catch((e) => {
        this.waitingForCheck = false;
        this.sendingSms = false;
        this.telno = null;
        if (e.message == 'voip phones not allowed') {
          this.error = "We don't allow voip phones. Please, try again with a different number";
        }
        this.error = 'The phone number you entered was incorrect. Please, try again.';
      });
  }

  check(code: number) {
    this.client.post('api/v1/twofactor/check/' + this.secret, {
      code: code,
      telno: this.telno
    })
      .then((response: any) => {
        this.waitingForCheck = false;
      })
      .catch((response: any) => {
        this.waitingForCheck = false;
        this.telno = null;
        this.error = 'The code was incorrect. Please, try again.';
      });
  }<commit_msg>(fix): send secret through $_POST<commit_after>import { Component } from '@angular/core';

import { Client } from '../../../services/api';
import { OverlayModalService } from '../../../services/ux/overlay-modal';
import { ConfirmPasswordModalComponent } from '../../modals/confirm-password/modal.component';

@Component({
  moduleId: module.id,
  selector: 'm-settings--two-factor',
  inputs: ['object'],
  templateUrl: 'two-factor.component.html'
})

export class SettingsTwoFactorComponent {

  minds: Minds;
  telno: number;
  secret;
  waitingForCheck: boolean = false;
  sendingSms: boolean = false;
  object: any;

  inProgress: boolean = false;
  error: string = '';

  constructor(public client: Client, private overlayModal: OverlayModalService) {
    this.minds = window.Minds;
    this.load();
  }

  load() {
    this.inProgress = true;
    this.client.get('api/v1/twofactor')
      .then((response: any) => {
        if (response.telno)
          this.telno = response.telno;
        this.inProgress = false;
      });
  }

  setup(smsNumber: any) {
    this.telno = smsNumber;
    this.waitingForCheck = true;
    this.sendingSms = true;
    this.error = '';
    this.client.post('api/v1/twofactor/setup', { tel: smsNumber })
      .then((response: any) => {
        this.secret = response.secret;
        this.sendingSms = false;
      })
      .catch((e) => {
        this.waitingForCheck = false;
        this.sendingSms = false;
        this.telno = null;
        if (e.message == 'voip phones not allowed') {
          this.error = "We don't allow voip phones. Please, try again with a different number";
        }
        this.error = 'The phone number you entered was incorrect. Please, try again.';
      });
  }

  check(code: number) {
    this.client.post('api/v1/twofactor/check', {
      code: code,
      telno: this.telno,
      secret: this.secret,
    })
      .then((response: any) => {
        this.waitingForCheck = false;
      })
      .catch((response: any) => {
        this.waitingForCheck = false;
        this.telno = null;
        this.error = 'The code was incorrect. Please, try again.';
      });
  }
{'fraction_non_alphanumeric': 0.14822645055203196, 'fraction_numerical': 0.0014094432699083862, 'mean_word_length': 2.5016447368421053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6270028', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1341, 'n_words': 301}