From b5f38595c2fb16b5edfbeeef63c9a21f838d1507 Mon Sep 17 00:00:00 2001 From: Hacer Gencer Date: Thu, 16 May 2019 19:00:16 +0300 Subject: [PATCH] =?UTF-8?q?differentSolutionRegister.ts=20sayfas=C4=B1=20o?= =?UTF-8?q?lu=C5=9Fturuldu.=20Sayfada=20register.page.ts=20sayfas=C4=B1nda?= =?UTF-8?q?n=20farkl=C4=B1=20olarak=20firebase=20veritaban=C4=B1na=20kay?= =?UTF-8?q?=C4=B1t=20i=C3=A7in=20user.service.ts=20sayfas=C4=B1ndaki=20met?= =?UTF-8?q?hodlar=C4=B1=20kullan=C4=B1lmam=C4=B1=C5=9Ft=C4=B1r.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/differentSolutionRegister.ts | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/app/differentSolutionRegister.ts diff --git a/src/app/differentSolutionRegister.ts b/src/app/differentSolutionRegister.ts new file mode 100644 index 0000000..3195b8e --- /dev/null +++ b/src/app/differentSolutionRegister.ts @@ -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); + } + } + +}