diff --git a/src/app/components/navbar/navbar.component.html b/src/app/components/navbar/navbar.component.html
index 533724cf..a82554f5 100644
--- a/src/app/components/navbar/navbar.component.html
+++ b/src/app/components/navbar/navbar.component.html
@@ -2,18 +2,7 @@
password strength: strong
@@ -75,7 +75,7 @@ Welcome!
-
+
diff --git a/src/app/pages/register/register.component.ts b/src/app/pages/register/register.component.ts
index 21cfa54e..565a9d69 100644
--- a/src/app/pages/register/register.component.ts
+++ b/src/app/pages/register/register.component.ts
@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
+import { AuthService } from 'src/app/services/auth.service';
@Component({
selector: 'app-register',
@@ -7,9 +9,38 @@ import { Component, OnInit } from '@angular/core';
})
export class RegisterComponent implements OnInit {
- constructor() { }
+ form: any = {
+ username: null,
+ email: null,
+ password: null
+ };
+ isSuccessful = false;
+ isSignUpFailed = false;
+ errorMessage = '';
- ngOnInit() {
+ constructor(private authService: AuthService,private router:Router) { }
+
+ ngOnInit(): void {
}
+ onSubmit(): void {
+ const { username, email, password } = this.form;
+ this.authService.register(username, email, password).subscribe(
+ data => {
+ console.log(data);
+ this.isSuccessful = true;
+ this.isSignUpFailed = false;
+ console.log('ok');
+ this.router.navigate(['/login'] );
+ },
+ err => {
+ this.errorMessage = err.error.message;
+ this.isSignUpFailed = true;
+ }
+ );
+ }
}
+
+
+
+
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index c1c8dbbf..209ea218 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -23,6 +23,8 @@ export class AuthService {
}
register(username: string, email: string, password: string): Observable {
+ console.log(username,email,password);
+
return this.http.post(AUTH_API + 'register', {
username,
email,
diff --git a/src/app/services/user.service.service.ts b/src/app/services/user.service.service.ts
index 97fa5f49..dd91265e 100644
--- a/src/app/services/user.service.service.ts
+++ b/src/app/services/user.service.service.ts
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
-const API_URL = 'http://localhost:8080/api/tsst/';
+const API_URL = 'http://localhost:8080/api/auth/';
@Injectable({
providedIn: 'root'
@@ -17,6 +17,9 @@ export class UserService {
getUserBoard(): Observable {
return this.http.get(API_URL + 'user', { responseType: 'text' });
}
+ getUser(): Observable {
+ return this.http.get(API_URL + 'login', { responseType: 'text' });
+ }
getModeratorBoard(): Observable {
return this.http.get(API_URL + 'mod', { responseType: 'text' });