Permalink
Browse files

Step 22.11: Implement a phone number verification

  • Loading branch information...
1 parent d5122a4 commit 77df4c7b18abdd724fd47356250749e0b064d938 @dotansimha dotansimha committed with DAB0mB Sep 27, 2016
Showing with 25 additions and 3 deletions.
  1. +25 −3 client/imports/app/auth/login.component.mobile.ts
@@ -1,6 +1,7 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit, NgZone} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
+import { Accounts } from 'meteor/accounts-base';
import template from './login.component.mobile.html';
@@ -10,8 +11,29 @@ import template from './login.component.mobile.html';
})
export class MobileLoginComponent implements OnInit {
error: string = '';
+ phoneForm: FormGroup;
+ phone: string;
- constructor(private router: Router, private formBuilder: FormBuilder) {}
+ constructor(private router: Router, private zone: NgZone, private formBuilder: FormBuilder) {}
- ngOnInit() {}
+ ngOnInit() {
+ this.phoneForm = this.formBuilder.group({
+ phone: ['', Validators.required]
+ });
+ }
+
+ send() {
+ if (this.phoneForm.valid) {
+ Accounts.requestPhoneVerification(this.phoneForm.value.phone, (err) => {
+ this.zone.run(() => {
+ if (err) {
+ this.error = err.reason || err;
+ } else {
+ this.phone = this.phoneForm.value.phone;
+ this.error = '';
+ }
+ });
+ });
+ }
+ }
}

0 comments on commit 77df4c7

Please sign in to comment.