Comment in data code
This commit is contained in:
parent
9530d1b57f
commit
33c915f4be
@ -12,14 +12,14 @@ const httpOptions = {
|
||||
export class AuthService {
|
||||
constructor(private http: HttpClient) {}
|
||||
login(username: string, password: string): Observable<any> {
|
||||
return this.http.post(AUTH_API + 'login', {
|
||||
return this.http.post(AUTH_API + '/login', {
|
||||
username,
|
||||
password,
|
||||
});
|
||||
}
|
||||
register(username: string, password: string): Observable<any> {
|
||||
return this.http.post(
|
||||
AUTH_API + 'signup',
|
||||
AUTH_API + '/register',
|
||||
{
|
||||
username,
|
||||
password,
|
||||
|
@ -1,22 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
const API_URL = 'http://localhost:8080/api/test/';
|
||||
const API_URL = 'https://aktienbot.flokaiser.com/api/user';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DataService {
|
||||
constructor(private http: HttpClient) {}
|
||||
// getPublicContent(): Observable<any> {
|
||||
// return this.http.get(API_URL + 'all', { responseType: 'text' });
|
||||
// }
|
||||
// getUserBoard(): Observable<any> {
|
||||
// return this.http.get(API_URL + 'user', { responseType: 'text' });
|
||||
// }
|
||||
// getModeratorBoard(): Observable<any> {
|
||||
// return this.http.get(API_URL + 'mod', { responseType: 'text' });
|
||||
// }
|
||||
// getAdminBoard(): Observable<any> {
|
||||
// return this.http.get(API_URL + 'admin', { responseType: 'text' });
|
||||
// }
|
||||
getPublicContent(): Observable<any> {
|
||||
return this.http.get(API_URL + 'all', { responseType: 'text' });
|
||||
}
|
||||
getUserBoard(): Observable<any> {
|
||||
return this.http.get(API_URL + 'user', { responseType: 'text' });
|
||||
}
|
||||
getModeratorBoard(): Observable<any> {
|
||||
return this.http.get(API_URL + 'mod', { responseType: 'text' });
|
||||
}
|
||||
getAdminBoard(): Observable<any> {
|
||||
return this.http.get(API_URL + 'admin', { responseType: 'text' });
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,23 @@
|
||||
</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">
|
||||
<button class="btn btn-primary btn-block">Sign Up</button>
|
||||
</div>
|
||||
|
@ -21,7 +21,6 @@ export class RegisterComponent implements OnInit {
|
||||
const { username, password } = this.form;
|
||||
this.authService.register(username, password).subscribe(
|
||||
(data) => {
|
||||
console.log(data);
|
||||
this.isSuccessful = true;
|
||||
this.isSignUpFailed = false;
|
||||
this.router.navigate(['/login']);
|
||||
|
@ -33,17 +33,17 @@ export class AppComponent {
|
||||
(event as NavigationEnd).url === '/login' ||
|
||||
(event as NavigationEnd).url === '/register'
|
||||
);
|
||||
// if (this.tokenStorage.getToken()) {
|
||||
// this.isLoggedIn = true;
|
||||
// } else {
|
||||
// this.isLoggedIn = false;
|
||||
// }
|
||||
// if (
|
||||
// this.isLoggedIn === false &&
|
||||
// (event as NavigationEnd).url != '/register'
|
||||
// ) {
|
||||
// this.router.navigate(['/login']);
|
||||
// }
|
||||
if (this.tokenStorage.getToken()) {
|
||||
this.isLoggedIn = true;
|
||||
} else {
|
||||
this.isLoggedIn = false;
|
||||
}
|
||||
if (
|
||||
this.isLoggedIn === false &&
|
||||
(event as NavigationEnd).url != '/register'
|
||||
) {
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user