Skip to content

Commit

Permalink
Step 5.14: Add verification component
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Dec 24, 2016
1 parent 1622c37 commit 495abfb
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/pages/verification/verification.ts
@@ -0,0 +1,53 @@
import { Component, OnInit, NgZone } from '@angular/core';
import { NavController, NavParams, AlertController } from 'ionic-angular';
import { Accounts } from 'meteor/accounts-base';

@Component({
selector: 'verification',
templateUrl: 'verification.html'
})
export class VerificationComponent implements OnInit {
code: string = '';
phone: string;

constructor(
public navCtrl: NavController,
public alertCtrl: AlertController,
public zone: NgZone,
public navParams: NavParams
) {}

ngOnInit() {
this.phone = this.navParams.get('phone');
}

onInputKeypress({keyCode}: KeyboardEvent): void {
if (keyCode == 13) {
this.verify();
}
}

verify(): void {
Accounts.verifyPhone(this.phone, this.code, (e: Error) => {
this.zone.run(() => {
if (e) return this.handleError(e);

// this.navCtrl.setRoot(ProfileComponent, {}, {
// animate: true
// });
});
});
}

private handleError(e: Error): void {
console.error(e);

const alert = this.alertCtrl.create({
title: 'Oops!',
message: e.message,
buttons: ['OK']
});

alert.present();
}
}

0 comments on commit 495abfb

Please sign in to comment.