-
\ No newline at end of file
diff --git a/src/app/register/register.component.scss b/src/app/register/register.component.scss
index e3d0685..f6144eb 100644
--- a/src/app/register/register.component.scss
+++ b/src/app/register/register.component.scss
@@ -1,17 +1,27 @@
-.header{
- text-align: center;
- font-size: 30px;
- margin-bottom: 40px;
+.header {
+ text-align: center;
+ font-size: 30px;
+ margin-bottom: 40px;
}
-.row{
- margin-top: 10px;
+.row {
+ margin-top: 10px;
}
-.error{
- color: red;
+.error {
+ color: red;
}
-.success{
- color: green;
+.success {
+ color: green;
}
+
+.button-container {
+ display: flex;
+ flex-direction: column;
+
+ button,
+ p {
+ margin: 5px 0;
+ }
+}
\ No newline at end of file
diff --git a/src/app/register/register.component.spec.ts b/src/app/register/register.component.spec.ts
new file mode 100644
index 0000000..8944bb3
--- /dev/null
+++ b/src/app/register/register.component.spec.ts
@@ -0,0 +1,21 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RegisterComponent } from './register.component';
+
+describe('RegisterComponent', () => {
+ let component: RegisterComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [RegisterComponent]
+ });
+ fixture = TestBed.createComponent(RegisterComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/register/register.component.ts b/src/app/register/register.component.ts
index 0d359b6..42a71da 100644
--- a/src/app/register/register.component.ts
+++ b/src/app/register/register.component.ts
@@ -1,18 +1,27 @@
import { Component } from '@angular/core';
-import { AuthService } from '../core/auth.service'
-import { Router, Params } from '@angular/router';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { CommonModule } from '@angular/common';
+import { FormGroup, FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
+import { Router, RouterModule } from '@angular/router';
+import { AuthService } from '../core/auth.service';
+import { AngularFireAuthModule } from '@angular/fire/compat/auth';
@Component({
selector: 'app-register',
+ standalone: true,
+ imports: [
+ CommonModule,
+ ReactiveFormsModule,
+ AngularFireAuthModule,
+ RouterModule
+ ],
+ providers: [AuthService],
templateUrl: './register.component.html',
styleUrls: ['./register.component.scss']
})
export class RegisterComponent {
-
- registerForm: FormGroup;
- errorMessage: string = '';
- successMessage: string = '';
+ registerForm!: FormGroup;
+ errorMessage = '';
+ successMessage = '';
constructor(
public authService: AuthService,
@@ -20,50 +29,51 @@ export class RegisterComponent {
private fb: FormBuilder
) {
this.createForm();
- }
+ }
- createForm() {
- this.registerForm = this.fb.group({
- email: ['', Validators.required ],
- password: ['',Validators.required]
- });
- }
+ createForm() {
+ this.registerForm = this.fb.group({
+ email: ['', Validators.required],
+ password: ['', Validators.required]
+ });
+ }
- tryFacebookLogin(){
- this.authService.doFacebookLogin()
- .then(res =>{
- this.router.navigate(['/user']);
- }, err => console.log(err)
- )
- }
+ tryFacebookLogin() {
+ this.authService.doFacebookLogin()
+ .then(res => {
+ this.router.navigate(['/user']);
+ }, err => console.log(err)
+ );
+ }
- tryTwitterLogin(){
- this.authService.doTwitterLogin()
- .then(res =>{
- this.router.navigate(['/user']);
- }, err => console.log(err)
- )
- }
+ tryTwitterLogin() {
+ this.authService.doTwitterLogin()
+ .then(res => {
+ this.router.navigate(['/user']);
+ }, err => console.log(err)
+ );
+ }
- tryGoogleLogin(){
- this.authService.doGoogleLogin()
- .then(res =>{
- this.router.navigate(['/user']);
- }, err => console.log(err)
- )
- }
+ tryGoogleLogin() {
+ this.authService.doGoogleLogin()
+ .then(res => {
+ this.router.navigate(['/user']);
+ }, err => console.log(err)
+ );
+ }
- tryRegister(value){
- this.authService.doRegister(value)
- .then(res => {
- console.log(res);
- this.errorMessage = "";
- this.successMessage = "Your account has been created";
- }, err => {
- console.log(err);
- this.errorMessage = err.message;
- this.successMessage = "";
- })
- }
+ get f() { return this.registerForm.controls; }
+ tryRegister() {
+
+ this.authService.doRegister(this.f['email'].value, this.f['password'].value)
+ .then(res => {
+ this.errorMessage = '';
+ this.successMessage = 'Your account has been created';
+ this.authService.doLogout();
+ }, err => {
+ this.errorMessage = err.message;
+ this.successMessage = '';
+ });
+ }
}
diff --git a/src/app/user/user.component.html b/src/app/user/user.component.html
index 8c07538..5d3e829 100644
--- a/src/app/user/user.component.html
+++ b/src/app/user/user.component.html
@@ -11,16 +11,16 @@
{{user.name}}
-
This is an example of Social Authentication using Firebase in an Angular 7 web app.
+
This is an example of Social Authentication using Firebase in an Angular 16 web app.
-
-
Save