Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/app/differentSolutionRegister.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Component, OnInit } from '@angular/core';
import { AlertController } from '@ionic/angular';
import { AngularFireAuth } from '@angular/fire/auth';
import { auth } from 'firebase/app'

@Component({
selector: 'app-register',
templateUrl: './register.page.html',
styleUrls: ['./register.page.scss'],
})
export class RegisterPage implements OnInit {

email: string = ""
password: string = ""
cpassword: string = ""

constructor(public alertController: AlertController, public fire: AngularFireAuth) {

}

ngOnInit() {
}

async presentAlert(content: string) {
const alert = await this.alertController.create({
message: content,
buttons: ['OK']
})

await alert.present()
}


registerUser() {
const { email, password, cpassword, isChecked } = this

if(password !== cpassword) {
console.error("Passwords don't match");
this.presentAlert('Passwords dont match');
}
try{
this.fire.auth.createUserWithEmailAndPassword(email, password)
this.presentAlert('Registered!')
this.router.navigate(['/tabs'])
}
}
catch(error) {
console.log('got an error ', error);
this.presentAlert(error.message);
}
}

}