1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 import { Component, OnInit } from '@angular/core';
\r
18 import { Router, ActivatedRoute } from '@angular/router';
\r
19 import { routerTransition } from '../router.animations';
\r
20 import { HttpClient } from '@angular/common/http';
\r
21 import { AppGlobals } from '../app.global';
\r
22 import { UserService } from '../shared/services/user.service';
\r
23 import { CookieService } from 'ngx-cookie-service';
\r
24 import { AuthService } from 'app/shared/services/auth.service';
\r
25 import { AlertModalComponent } from '../shared/modules/alert-modal/alert-modal.component';
\r
26 import { MatDialog } from '@angular/material';
\r
31 selector: 'app-login',
\r
32 templateUrl: './login.component.html',
\r
34 styleUrls: ['./login.component.scss'],
\r
35 animations: [routerTransition()]
\r
37 export class LoginComponent implements OnInit {
\r
41 public loginFailed = false;
\r
43 constructor(public router: Router,
\r
44 private route: ActivatedRoute,
\r
45 private http: HttpClient,
\r
46 private _global: AppGlobals,
\r
47 private cookie: CookieService,
\r
48 private dialog: MatDialog,
\r
49 private auth: AuthService
\r
54 this.User.email = "";
\r
55 this.User.password = "";
\r
60 this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
\r
64 //alert("User email: " + this.User.email + " User password: " + this.User.password);
\r
65 this.auth.login(this.User) //need to use /authorization
\r
68 if(this.cookie.check('access_token')){
\r
69 this.router.navigate([this.returnUrl]);
\r
71 if (authResult['user'] && !authResult['user']['enabled']) {
\r
72 this.dialog.open(AlertModalComponent, {
\r
76 message: "Your account is not yet enabled. Please wait for approval."
\r
81 this.dialog.open(AlertModalComponent, {
\r
85 message: "Something went wrong... Please Refresh and try again."
\r
92 this.loginFailed = true;
\r
93 this.dialog.open(AlertModalComponent, {
\r
97 message: error + " Please try again"
\r