Skip to content
Permalink
e21c1c6f10
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
49 lines (37 sloc) 1.15 KB
import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { LoginService } from '../services/login.service'
import 'rxjs/Rx';
import { Observable } from 'rxjs/Rx';
@Injectable()
@Component({
selector: 'app-authentication',
templateUrl: './authentication.component.html',
styleUrls: ['./authentication.component.css']
})
export class AuthenticationComponent implements OnInit {
private items: Array<string>;
constructor(private data: LoginService) {
this.items = ["username", "password"]
}
logOn (event: any) {
event.preventDefault();
let username: HTMLElement = document.getElementById('email');
let password: HTMLElement = document.getElementById('password');
username.click();
password.click();
var json = JSON.stringify({
"user_email": username,
"user_password": password
});
var authInfo = this.data.authorizeUser(json);
var authorized = authInfo["message"];
var token = authInfo["token"];
if (authorized) {
return token;
}
this.data.getUser(token);
}
ngOnInit() { }
}