Skip to content

Commit

Permalink
initial creation of login service and changes to authenticationand ap…
Browse files Browse the repository at this point in the history
…p module to set up
  • Loading branch information
rrc12004 committed Feb 27, 2019
1 parent be32550 commit 7a8499b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';

import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand Down Expand Up @@ -28,8 +29,9 @@ import { SignUpComponent } from './sign-up/sign-up.component';
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
RouterModule.forRoot([

{path: 'dashboard', component: FrontpageComponent},
{path: '', component: AuthenticationComponent},
{path: 'generator-search', component: GeneratorSearchComponent},
Expand Down
3 changes: 2 additions & 1 deletion src/app/authentication/authentication.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h4 class="text-center mb-3">Log In</h4>
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<a routerLink="/generator-search"><button type="submit" class="btn btn-primary">Submit</button></a>
<!-- <a routerLink="/generator-search"><button type="submit" class="btn btn-primary">Submit</button></a> -->
<button type="submit" class="btn btn-primary" id="login-button" ng-click="LogOn()">Submit</button>
</form>
<p>
<br>
Expand Down
13 changes: 12 additions & 1 deletion src/app/authentication/authentication.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { LoginService } from '../services/login.service'

@Injectable()

@Component({
selector: 'app-authentication',
Expand All @@ -7,9 +12,15 @@ import { Component, OnInit } from '@angular/core';
})
export class AuthenticationComponent implements OnInit {

constructor() { }
constructor(private data: LoginService) { }

ngOnInit() {

this.data.authorizeUser().subscribe(data =>
{
// this.users$ = data;
});

}

}
12 changes: 12 additions & 0 deletions src/app/services/login.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { LoginService } from './login.service';

describe('LoginService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: LoginService = TestBed.get(LoginService);
expect(service).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions src/app/services/login.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Observable } from 'rxjs/Observable';

@Injectable({
providedIn: 'root'
})
export class LoginService {

constructor(private http: HttpClient) { }

authorizeUser() {
return this.http.get('http://sd5-backend.engr.uconn.edu/auth')
}

getUser() {
return this.http.get('http://sd5-backend.engr.uconn.edu/user/me')
}
}

0 comments on commit 7a8499b

Please sign in to comment.