aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/vnfs/userlogin-form
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/vnfs/userlogin-form')
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.html8
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts6
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.ts89
3 files changed, 15 insertions, 88 deletions
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.html b/src/app/vnfs/userlogin-form/userlogin-form.component.html
index 069583e..3f18b72 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.html
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.html
@@ -1,7 +1,7 @@
<!--
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -32,10 +32,6 @@ limitations under the License.
[(ngModel)]="userId" name="userId" value="" #user="ngModel" (ngModelChange)="validateUserName()">
<span class="error-message">{{errorMessage}}</span>
</div>
- <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
- <input type="password" placeholder="Enter password" class="mdl-textfield__input" id="password" required
- [(ngModel)]="password" name="password" value="" (ngModelChange)="validatePassword()" >
- </div>
<div class="form-group text-right">
<button type="submit" [disabled]="invalid"
@@ -47,4 +43,4 @@ limitations under the License.
</div>
</div>
</div>
-</div>
+</div> \ No newline at end of file
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts
index bf8431b..712d1bf 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
Modification Copyright (C) 2018 IBM
===================================================================
@@ -64,7 +64,7 @@ describe('userloginFormComponent', () => {
fixture = TestBed.createComponent(userloginFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- // sessionStorage['userId'] = "testUser"
+ // localStorage['userId'] = "testUser"
component.userId = 'test Usr';
});
@@ -99,7 +99,7 @@ describe('userloginFormComponent', () => {
expect(url.length).toBe(5);
expect(url[0]).toEqual('/');
expect(url[1]).toEqual('h');
- expect(sessionStorage['userId']).toBe('test Usr');
+ expect(localStorage['userId']).toBe('test Usr');
}));
it('test validateUserName function', () => {
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.ts
index 7ed087e..c62e9bb 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.ts
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -23,24 +23,19 @@ import {Component, OnInit} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {EmitterService} from '../../shared/services/emitter.service';
-import { environment } from '../../../environments/environment';
-import { HttpUtilService } from '../../shared/services/httpUtil/http-util.service';
import {Router} from '@angular/router';
-import { NgProgress } from 'ngx-progressbar';
import {UtilityService} from '../../shared/services/utilityService/utility.service';
-import { Http, Response, Headers, RequestOptions } from '@angular/http';
@Component({selector: 'app-mvnfs-form', templateUrl: './userlogin-form.component.html', styleUrls: ['./userlogin-form.component.css']})
export class userloginFormComponent implements OnInit {
userId: string = '';
- password: string = '';
returnUrl:string
invalid = true;
errorMessage = '';
- constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute,
- private http: Http, private ngProgress: NgProgress) {
+ constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute
+ ) {
}
ngOnInit() {
@@ -49,57 +44,12 @@ export class userloginFormComponent implements OnInit {
getData() {
- this.ngProgress.start();
- var getHeader = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON
- var authStr = btoa(this.userId + ':' + this.password);
- const options = {
- headers: new Headers({
- 'Content-Type': 'application/json',
- 'Authorization': 'Basic ' + authStr
- }),
- observe: 'response'
- };
- const data = {
- 'input': {
- 'design-request': {
- 'request-id': '1',
- 'action': 'getDesigns',
- 'payload': '{"userID": "","filter":"reference"}'
- }
- }
- };
- const x = JSON.parse(data.input['design-request']['payload']);
- x.userID = this.userId;
- data.input['design-request']['payload'] = JSON.stringify(x);
- console.log("auth " + btoa(this.userId + ':' + this.password));
- this.http.post(environment.getDesigns,data,options).subscribe(resp => {
- console.log("status " + resp.status);
- if(resp.status == 200){
- console.log('logged in');
- sessionStorage['userId'] = this.userId;
- sessionStorage['apiToken'] = this.utiltiy.randomId();
- sessionStorage['auth'] = authStr;
- EmitterService
- .get('userLogin')
- .emit(this.userId);
- this.router.navigateByUrl(this.returnUrl);
- } else {
- console.log("Invalid user or password");
- this.invalid = true;
- this.errorMessage = 'Invalid user or password';
- }
- }, error => {
- console.log(error);
- if(error.status == 401){
- this.invalid = true;
- this.errorMessage = 'Invalid user or password';
- } else {
- this.invalid = true;
- this.errorMessage = 'Incorrect login or connection error.';
- }
- });
- console.log("After");
-
+ localStorage['userId'] = this.userId;
+ localStorage['apiToken'] = this.utiltiy.randomId();
+ EmitterService
+ .get('userLogin')
+ .emit(this.userId);
+ this.router.navigateByUrl(this.returnUrl);
}
validateUserName(){
@@ -107,7 +57,7 @@ export class userloginFormComponent implements OnInit {
this.errorMessage = '';
this.invalid = true;
}else if(this.userId.startsWith(' ') || this.userId.endsWith(' ')){
- this.errorMessage = 'Leading and trailing space is not allowed in username';
+ this.errorMessage = 'Leading and trailing space is not allowed';
this.invalid = true;
} else if(this.userId.includes(' ')){
this.errorMessage = 'More than one space is not allowed in username';
@@ -120,24 +70,5 @@ export class userloginFormComponent implements OnInit {
this.errorMessage = '';
}
}
-
- validatePassword(){
- if (!this.password.trim() || this.password.length < 1) {
- this.errorMessage = '';
- this.invalid = true;
- }else if(this.password.startsWith(' ') || this.password.endsWith(' ')){
- this.errorMessage = 'Leading and trailing space is not allowed in password';
- this.invalid = true;
- } else if(this.password.includes(' ')){
- this.errorMessage = 'More than one space is not allowed in password';
- this.invalid = true;
- } else if(this.password.length > 50) {
- this.errorMessage = 'Password should be of minimum one character and maximum 50 character';
- this.invalid = true;
- }else {
- this.invalid = false;
- this.errorMessage = '';
- }
- }
}