<commit_before>import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';

import {AuthService} from '../services/auth.service';

@Component({
  selector: 'fci-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent {
  email: string;
  password: string;

  isLoggingIn = false;
  hasError = false;

  constructor(
      private readonly authService: AuthService,
      private readonly router: Router) {}

  login(): void {
    this.isLoggingIn = true;
    this.hasError = false;

    this.authService.login({email: this.email, password: this.password})
        .subscribe(() => {
          this.isLoggingIn = false;

          // TODO: preserve user's state and return to that instead
          // Logged-in go back to landing page
          this.router.navigate(['/']);
        }, () => {<commit_msg>Redirect /login to /dashboard if logged in (#1022)<commit_after>import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';

import {AuthService} from '../services/auth.service';

@Component({
  selector: 'fci-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  email: string;
  password: string;

  isLoggingIn = false;
  hasError = false;

  constructor(
      private readonly authService: AuthService,
      private readonly router: Router) {}

  ngOnInit() {
    if (this.authService.isLoggedIn()) {
      this.router.navigate(['/dashboard']);
    }
  }

  login(): void {
    this.isLoggingIn = true;
    this.hasError = false;

    this.authService.login({email: this.email, password: this.password})
        .subscribe(() => {
          this.isLoggingIn = false;

          // TODO: preserve user's state and return to that instead
          // Logged-in go back to landing page
          this.router.navigate(['/']);
        }, () => {
{'fraction_non_alphanumeric': 0.14234693877551022, 'fraction_numerical': 0.0020408163265306124, 'mean_word_length': 3.0184426229508197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2342280', 'n_tokens_mistral': 586, 'n_tokens_neox': 572, 'n_words': 151}