diff --git a/kibicara-frontend/src/app/login/login.component.scss b/kibicara-frontend/src/app/auth/login/login.component.scss
similarity index 100%
rename from kibicara-frontend/src/app/login/login.component.scss
rename to kibicara-frontend/src/app/auth/login/login.component.scss
diff --git a/kibicara-frontend/src/app/login/login.component.spec.ts b/kibicara-frontend/src/app/auth/login/login.component.spec.ts
similarity index 100%
rename from kibicara-frontend/src/app/login/login.component.spec.ts
rename to kibicara-frontend/src/app/auth/login/login.component.spec.ts
diff --git a/kibicara-frontend/src/app/login/login.component.ts b/kibicara-frontend/src/app/auth/login/login.component.ts
similarity index 83%
rename from kibicara-frontend/src/app/login/login.component.ts
rename to kibicara-frontend/src/app/auth/login/login.component.ts
index fddaac4..e1b1f4b 100644
--- a/kibicara-frontend/src/app/login/login.component.ts
+++ b/kibicara-frontend/src/app/auth/login/login.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { LoginService } from '../core/auth/login.service';
+import { LoginService } from '../../core/auth/login.service';
import { Router, ActivatedRoute } from '@angular/router';
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
import { first } from 'rxjs/operators';
@@ -15,6 +15,7 @@ export class LoginComponent implements OnInit {
error: string;
loading = false;
submitted = false;
+ info: string;
constructor(
private loginService: LoginService,
@@ -32,7 +33,12 @@ export class LoginComponent implements OnInit {
email: ['', Validators.required],
password: ['', Validators.required],
});
- this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/dashboard';
+ this.returnUrl =
+ this.route.snapshot.queryParams['returnUrl'] || '/dashboard';
+
+ if (this.route.snapshot.queryParams['registered'] === true) {
+ this.info = 'Registration infoful';
+ }
}
onSubmit() {
diff --git a/kibicara-frontend/src/app/auth/register/register.component.html b/kibicara-frontend/src/app/auth/register/register.component.html
new file mode 100644
index 0000000..5116afb
--- /dev/null
+++ b/kibicara-frontend/src/app/auth/register/register.component.html
@@ -0,0 +1,56 @@
+
{{ error }}
+
{{ info }}
+
Register
+
diff --git a/kibicara-frontend/src/app/register/register.component.scss b/kibicara-frontend/src/app/auth/register/register.component.scss
similarity index 100%
rename from kibicara-frontend/src/app/register/register.component.scss
rename to kibicara-frontend/src/app/auth/register/register.component.scss
diff --git a/kibicara-frontend/src/app/register/register.component.spec.ts b/kibicara-frontend/src/app/auth/register/register.component.spec.ts
similarity index 100%
rename from kibicara-frontend/src/app/register/register.component.spec.ts
rename to kibicara-frontend/src/app/auth/register/register.component.spec.ts
diff --git a/kibicara-frontend/src/app/auth/register/register.component.ts b/kibicara-frontend/src/app/auth/register/register.component.ts
new file mode 100644
index 0000000..57678a4
--- /dev/null
+++ b/kibicara-frontend/src/app/auth/register/register.component.ts
@@ -0,0 +1,57 @@
+import { Component, OnInit } from '@angular/core';
+import { AdminService } from '../../core/api';
+import { Validators, FormBuilder, FormGroup } from '@angular/forms';
+import { first } from 'rxjs/operators';
+import { Router, ActivatedRoute } from '@angular/router';
+
+@Component({
+ selector: 'app-register',
+ templateUrl: './register.component.html',
+ styleUrls: ['./register.component.scss'],
+})
+export class RegisterComponent implements OnInit {
+ registerForm: FormGroup;
+ loading = false;
+ submitted = false;
+ error: string;
+ info: string;
+
+ constructor(
+ private readonly adminService: AdminService,
+ private formBuilder: FormBuilder,
+ private route: ActivatedRoute
+ ) {}
+
+ ngOnInit(): void {
+ this.registerForm = this.formBuilder.group({
+ email: ['', Validators.required],
+ password: ['', [Validators.required, Validators.minLength(6)]],
+ });
+
+ if (this.route.snapshot.queryParams['error']) {
+ this.error = 'Invalid confirmation link. Try registering again';
+ }
+ }
+
+ onSubmit() {
+ this.submitted = true;
+ if (this.registerForm.invalid) {
+ return;
+ }
+ this.loading = true;
+ this.adminService
+ .register(this.registerForm.value)
+ .pipe(first())
+ .subscribe(
+ (data) => {
+ this.info =
+ 'Registration E-Mail has been sent. Please check your inbox.';
+ this.loading = false;
+ },
+ (error) => {
+ this.error = 'Registration failed! E-Mail exists or is not valid.';
+ this.loading = false;
+ }
+ );
+ }
+}
diff --git a/kibicara-frontend/src/app/register/register.component.html b/kibicara-frontend/src/app/register/register.component.html
deleted file mode 100644
index 6b0ba2e..0000000
--- a/kibicara-frontend/src/app/register/register.component.html
+++ /dev/null
@@ -1 +0,0 @@
-
register works!
diff --git a/kibicara-frontend/src/app/register/register.component.ts b/kibicara-frontend/src/app/register/register.component.ts
deleted file mode 100644
index 8f62eda..0000000
--- a/kibicara-frontend/src/app/register/register.component.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'app-register',
- templateUrl: './register.component.html',
- styleUrls: ['./register.component.scss']
-})
-export class RegisterComponent implements OnInit {
-
- constructor() { }
-
- ngOnInit(): void {
- }
-
-}