<commit_before>/*
 *    Copyright 2016 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
import { Component, OnInit, Inject } from '@angular/core';
import { QuoteoverviewComponent } from '../quoteoverview/quoteoverview.component';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MyuserService } from '../../services/myuser.service';
import { MyUser } from '../../common/my-user';
import { FormGroup, FormControl, FormBuilder, Validators, AbstractControl } from '@angular/forms';
import { TokenService } from 'ngx-simple-charts/base-service';


enum FormFields {
	username = 'username',
	password = 'password',
	password2 = '<PASSWORD>',
	email = 'email',
}

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  protected signinForm: FormGroup;
  protected loginForm: FormGroup;
  protected loginFailed = false;
  protected signinFailed = false;
  protected pwMatching = true;
  protected formFields = FormFields;
  private user = new MyUser();

  constructor(public dialogRef: MatDialogRef<QuoteoverviewComponent>, private tokenService: TokenService,
          @Inject(MAT_DIALOG_DATA) public data: any, private myuserService: MyuserService, fb: FormBuilder) {
      this.signinForm = fb.group({
          [FormFields.username]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.password]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.password2]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.email]: ['', Validators.required]
      },{
          validator: this.validate.bind(this)
      });
      this.loginForm = fb.group({
          [FormFields.username]: ['', Validators.required],
          [FormFields.password]: ['', Validators.required]
      });
  }

  ngOnInit() {}

  validate(group: FormGroup) {
      if(group.get(FormFields.password).touched || group.get(FormFields.password2).touched) {<commit_msg>fix: validation<commit_after>/*
 *    Copyright 2016 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
import { Component, OnInit, Inject } from '@angular/core';
import { QuoteoverviewComponent } from '../quoteoverview/quoteoverview.component';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MyuserService } from '../../services/myuser.service';
import { MyUser } from '../../common/my-user';
import { FormGroup, FormControl, FormBuilder, Validators, AbstractControl } from '@angular/forms';
import { TokenService } from 'ngx-simple-charts/base-service';


enum FormFields {
	username = 'username',
	password = 'password',
	password2 = '<PASSWORD>',
	email = 'email',
}

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  protected signinForm: FormGroup;
  protected loginForm: FormGroup;
  protected loginFailed = false;
  protected signinFailed = false;
  protected pwMatching = true;
  protected formFields = FormFields;
  private user = new MyUser();

  constructor(public dialogRef: MatDialogRef<QuoteoverviewComponent>, private tokenService: TokenService,
          @Inject(MAT_DIALOG_DATA) public data: any, private myuserService: MyuserService, fb: FormBuilder) {
      this.signinForm = fb.group({
          [FormFields.username]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.password]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.password2]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.email]: ['', Validators.required]
      },{
          validator: this.validate.bind(this)
      });
      this.loginForm = fb.group({
          [FormFields.username]: ['', [Validators.required, Validators.minLength(4)]],
          [FormFields.password]: ['', [Validators.required, Validators.minLength(4)]]
      });
  }

  ngOnInit() {}

  validate(group: FormGroup) {
      if(group.get(FormFields.password).touched || group.get(FormFields.password2).touched) {
{'fraction_non_alphanumeric': 0.1252397391637898, 'fraction_numerical': 0.005753739930955121, 'mean_word_length': 3.98565965583174, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1461882', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1444, 'n_words': 409}