Add login capability; Add register page to routing; Block access from users that are not logged in.
This commit is contained in:
@@ -1,34 +1,30 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
const AUTH_API = 'http://localhost:8080/api/auth/';
|
||||
const AUTH_API = 'https://aktienbot.flokaiser.com/api/';
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
constructor(private http: HttpClient) {}
|
||||
// login(username: string, password: string): Observable<any> {
|
||||
// return this.http.post(
|
||||
// AUTH_API + 'signin',
|
||||
// {
|
||||
// username,
|
||||
// password,
|
||||
// },
|
||||
// httpOptions
|
||||
// );
|
||||
// }
|
||||
// register(username: string, email: string, password: string): Observable<any> {
|
||||
// return this.http.post(
|
||||
// AUTH_API + 'signup',
|
||||
// {
|
||||
// username,
|
||||
// email,
|
||||
// password,
|
||||
// },
|
||||
// httpOptions
|
||||
// );
|
||||
// }
|
||||
login(username: string, password: string): Observable<any> {
|
||||
return this.http.post(AUTH_API + 'login', {
|
||||
username,
|
||||
password,
|
||||
});
|
||||
}
|
||||
register(username: string, password: string): Observable<any> {
|
||||
return this.http.post(
|
||||
AUTH_API + 'signup',
|
||||
{
|
||||
username,
|
||||
password,
|
||||
},
|
||||
httpOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ const API_URL = 'http://localhost:8080/api/test/';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
export class DataService {
|
||||
constructor(private http: HttpClient) {}
|
||||
// getPublicContent(): Observable<any> {
|
||||
// return this.http.get(API_URL + 'all', { responseType: 'text' });
|
||||
|
||||
Reference in New Issue
Block a user