text: var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
      else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
      return c > 3 && r && Object.defineProperty(target, key, r), r;
  };
  var __metadata = (this && this.__metadata) || function (k, v) {
      if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  };
  import { Component } from '@angular/core';
  import { AuthService } from '../../services/auth.service';
  import { Router } from '@angular/router';
  import { FlashMessagesService } from 'angular2-flash-messages';
  var LoginComponent = (function () {
      function LoginComponent(authService, router, flashMessage) {
          this.authService = authService;
          this.router = router;
          this.flashMessage = flashMessage;
      }
      LoginComponent.prototype.ngOnInit = function () {
      };
      LoginComponent.prototype.onLoginSubmit = function () {
          var _this = this;
          var user = {
              username: this.username,
              password: this.password
          };
          this.authService.authenticateUser(user).subscribe(function (data) {
              if (data.success) {
                  _this.authService.storeUserData(data.token, data.user);
                  _this.flashMessage.show('You are now logged in', {
                      cssClass: 'alert-success',
                      timeout: 5000
                  });
                  _this.router.navigate(['dashboard']);
              }
              else {
                  _this.flashMessage.show(data.msg, {
                      cssClass: 'alert-danger',
                      timeout: 5000
                  });
                  _this.router.navigate(['login']);
              }
          });
      };
      return LoginComponent;
  }());
  LoginComponent = __decorate([
      Component({
          selector: 'app-login',
          templateUrl: './login.component.html',
          styleUrls: ['./login.component.css']
      }),
      __metadata("design:paramtypes", [AuthService,
          Router,
          FlashMessagesService])
  ], LoginComponent);
  export { LoginComponent };
  //# sourceMappingURL=../../../../../src/app/components/login/login.component.js.map