Comment in data code

This commit is contained in:
kevinpauer 2022-03-19 22:11:29 +01:00
parent 9530d1b57f
commit 33c915f4be
5 changed files with 43 additions and 27 deletions

View File

@ -12,14 +12,14 @@ const httpOptions = {
export class AuthService { export class AuthService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
login(username: string, password: string): Observable<any> { login(username: string, password: string): Observable<any> {
return this.http.post(AUTH_API + 'login', { return this.http.post(AUTH_API + '/login', {
username, username,
password, password,
}); });
} }
register(username: string, password: string): Observable<any> { register(username: string, password: string): Observable<any> {
return this.http.post( return this.http.post(
AUTH_API + 'signup', AUTH_API + '/register',
{ {
username, username,
password, password,

View File

@ -1,22 +1,22 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
const API_URL = 'http://localhost:8080/api/test/'; const API_URL = 'https://aktienbot.flokaiser.com/api/user';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class DataService { export class DataService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
// getPublicContent(): Observable<any> { getPublicContent(): Observable<any> {
// return this.http.get(API_URL + 'all', { responseType: 'text' }); return this.http.get(API_URL + 'all', { responseType: 'text' });
// } }
// getUserBoard(): Observable<any> { getUserBoard(): Observable<any> {
// return this.http.get(API_URL + 'user', { responseType: 'text' }); return this.http.get(API_URL + 'user', { responseType: 'text' });
// } }
// getModeratorBoard(): Observable<any> { getModeratorBoard(): Observable<any> {
// return this.http.get(API_URL + 'mod', { responseType: 'text' }); return this.http.get(API_URL + 'mod', { responseType: 'text' });
// } }
// getAdminBoard(): Observable<any> { getAdminBoard(): Observable<any> {
// return this.http.get(API_URL + 'admin', { responseType: 'text' }); return this.http.get(API_URL + 'admin', { responseType: 'text' });
// } }
} }

View File

@ -53,6 +53,23 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<label for="password">Confirm Password</label>
<input
type="password"
class="form-control"
name="passwordRepeat"
[(ngModel)]="form.password"
required
minlength="6"
#passwordRepeat="ngModel"
/>
<div class="alert-danger" *ngIf="password.errors && f.submitted">
<div *ngIf="passwordRepeat.errors?.['required']">
Confirmation is required
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary btn-block">Sign Up</button> <button class="btn btn-primary btn-block">Sign Up</button>
</div> </div>

View File

@ -21,7 +21,6 @@ export class RegisterComponent implements OnInit {
const { username, password } = this.form; const { username, password } = this.form;
this.authService.register(username, password).subscribe( this.authService.register(username, password).subscribe(
(data) => { (data) => {
console.log(data);
this.isSuccessful = true; this.isSuccessful = true;
this.isSignUpFailed = false; this.isSignUpFailed = false;
this.router.navigate(['/login']); this.router.navigate(['/login']);

View File

@ -33,17 +33,17 @@ export class AppComponent {
(event as NavigationEnd).url === '/login' || (event as NavigationEnd).url === '/login' ||
(event as NavigationEnd).url === '/register' (event as NavigationEnd).url === '/register'
); );
// if (this.tokenStorage.getToken()) { if (this.tokenStorage.getToken()) {
// this.isLoggedIn = true; this.isLoggedIn = true;
// } else { } else {
// this.isLoggedIn = false; this.isLoggedIn = false;
// } }
// if ( if (
// this.isLoggedIn === false && this.isLoggedIn === false &&
// (event as NavigationEnd).url != '/register' (event as NavigationEnd).url != '/register'
// ) { ) {
// this.router.navigate(['/login']); this.router.navigate(['/login']);
// } }
}); });
} }
} }